Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Mon, 25 Jul 2016 11:48:50 +0200
From: Julien Ramseier <j.ramseier@...il.com>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] newlocale: set errno on failure

Oops I did miss that.
Sorry for the noise.

- Julien

> Le 25 juil. 2016 à 11:46, Alexander Monakov <amonakov@...ras.ru> a écrit :
> 
> On Mon, 25 Jul 2016, Julien Ramseier wrote:
>> 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;
> 
> When malloc returns NULL, it will set errno to ENOMEM; there's no need for
> callers to handle that separately.
> 
> Did you hit some issue in practice that prompted this change?
> 
> Alexander


Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.