From: eaglegai Date: Fri, 26 May 2023 08:44:34 +0000 (+0800) Subject: BUG/MINOR: thread: add a check for pthread_create X-Git-Tag: v2.8.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef667b1ad89bb159b1991de0ec07d17e4320df23;p=thirdparty%2Fhaproxy.git BUG/MINOR: thread: add a check for pthread_create 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. --- diff --git a/src/thread.c b/src/thread.c index d7128252ed..b41b6628a4 100644 --- a/src/thread.c +++ b/src/thread.c @@ -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)