From ee835a1aaaabeb4dbb06093c9c327f5af0ceb8b1 Mon Sep 17 00:00:00 2001 From: moce Date: Tue, 5 Nov 2024 17:58:11 +0800 Subject: [PATCH] fix #276: double-free panic in gcc attribute destructor logging --- src/zlog.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/zlog.c b/src/zlog.c index 66d7507..df24e93 100644 --- a/src/zlog.c +++ b/src/zlog.c @@ -64,10 +64,18 @@ static void zlog_fini_inner(void) static void zlog_clean_rest_thread(void) { + int rc; + zlog_thread_t *a_thread; a_thread = pthread_getspecific(zlog_thread_key); if (!a_thread) return; zlog_thread_del(a_thread); + + rc = pthread_setspecific(zlog_thread_key, NULL); + if (rc) { + zc_error("pthread_setspecific fail, rc[%d]", rc); + return; + } return; }