From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26193 invoked from network); 12 Nov 2022 13:31:47 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 12 Nov 2022 13:31:47 -0000 Received: (qmail 11319 invoked by uid 550); 12 Nov 2022 13:31:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 11287 invoked from network); 12 Nov 2022 13:31:42 -0000 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 499CD419E9DF From: Alexey Izbyshev To: musl@lists.openwall.com Date: Sat, 12 Nov 2022 16:31:01 +0300 Message-Id: <20221112133101.253026-1-izbyshev@ispras.ru> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Mail-Followup-To: musl@lists.openwall.com Content-Transfer-Encoding: 8bit Subject: [musl] [PATCH] pthread_atfork: fix return value on malloc failure POSIX requires pthread_atfork to report errors via its return value, not via errno. The only specified error is ENOMEM. --- 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 #include #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