Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 13 Nov 2022 16:20:23 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] pthread_atfork: fix return value on malloc failure

* Alexey Izbyshev <izbyshev@...ras.ru> [2022-11-12 16:31:01 +0300]:
> POSIX requires pthread_atfork to report errors via its return value,
> not via errno. The only specified error is ENOMEM.

this patch looks good.


> ---
>  src/thread/pthread_atfork.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/thread/pthread_atfork.c b/src/thread/pthread_atfork.c
> index 76497401..2fbe23ca 100644
> --- a/src/thread/pthread_atfork.c
> +++ b/src/thread/pthread_atfork.c
> @@ -1,3 +1,4 @@
> +#include <errno.h>
>  #include <pthread.h>
>  #include "libc.h"
>  #include "lock.h"
> @@ -34,7 +35,7 @@ void __fork_handler(int who)
>  int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
>  {
>  	struct atfork_funcs *new = malloc(sizeof *new);
> -	if (!new) return -1;
> +	if (!new) return ENOMEM;
>  
>  	LOCK(lock);
>  	new->next = funcs;
> -- 
> 2.37.2

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.