From cf0d4994c29a3e81623536bfcf1946eb41c03fd9 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Mon, 15 Feb 2021 21:15:52 +0100 Subject: [PATCH] LibC+LibPthread: Permit partial pthread_atfork POSIX explicitly allows providing nullptr's, and our __pthread_*() implementation stores and calls the provided functions as-is, without checking for nullptr. --- Userland/Libraries/LibPthread/pthread.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPthread/pthread.cpp b/Userland/Libraries/LibPthread/pthread.cpp index dbbe2aee4c..a106dff42d 100644 --- a/Userland/Libraries/LibPthread/pthread.cpp +++ b/Userland/Libraries/LibPthread/pthread.cpp @@ -900,9 +900,12 @@ int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int) int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) { - __pthread_fork_atfork_register_prepare(prepare); - __pthread_fork_atfork_register_parent(parent); - __pthread_fork_atfork_register_child(child); + if (prepare) + __pthread_fork_atfork_register_prepare(prepare); + if (parent) + __pthread_fork_atfork_register_parent(parent); + if (child) + __pthread_fork_atfork_register_child(child); return 0; }