Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.20.13.1607251243030.19688@monopod.intra.ispras.ru>
Date: Mon, 25 Jul 2016 12:46:53 +0300 (MSK)
From: Alexander Monakov <amonakov@...ras.ru>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] newlocale: set errno on failure

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

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.