mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] newlocale: set errno on failure
@ 2016-07-25  9:35 Julien Ramseier
  2016-07-25  9:46 ` Alexander Monakov
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Ramseier @ 2016-07-25  9:35 UTC (permalink / raw)
  To: musl

As per POSIX, newlocale() should set errno when it fails.

---
 src/locale/newlocale.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/locale/newlocale.c b/src/locale/newlocale.c
index f50bbe9..2bfb832 100644
--- a/src/locale/newlocale.c
+++ b/src/locale/newlocale.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include "locale_impl.h"
@@ -42,6 +43,7 @@ locale_t __newlocale(int mask, const char *name, locale_t loc)
 		return UTF8_LOCALE;

 	if ((loc = malloc(sizeof *loc))) *loc = tmp;
+	else errno = ENOMEM;

 	return loc;
 }
--
2.9.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-25  9:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-25  9:35 [PATCH] newlocale: set errno on failure Julien Ramseier
2016-07-25  9:46 ` Alexander Monakov
2016-07-25  9:48   ` Julien Ramseier

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).