]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: thread: add a check for pthread_create
authoreaglegai <eaglegai@163.com>
Fri, 26 May 2023 08:44:34 +0000 (16:44 +0800)
committerWilly Tarreau <w@1wt.eu>
Fri, 26 May 2023 10:08:23 +0000 (12:08 +0200)
preload_libgcc_s() use pthread_create to create a thread and then call
pthread_join to use it, but it doesn't check if the option is successful.
So add a check to aviod potential crash.

src/thread.c

index d7128252ed0ea4f258369163280bcf409eb9c429..b41b6628a4cbbb4e490a0f18baaf5af752c08bf7 100644 (file)
@@ -1066,8 +1066,8 @@ static void *dummy_thread_function(void *data)
 static inline void preload_libgcc_s(void)
 {
        pthread_t dummy_thread;
-       pthread_create(&dummy_thread, NULL, dummy_thread_function, NULL);
-       pthread_join(dummy_thread, NULL);
+       if (pthread_create(&dummy_thread, NULL, dummy_thread_function, NULL) == 0)
+               pthread_join(dummy_thread, NULL);
 }
 
 static void __thread_init(void)