]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Recycle the TLS key that holds thread_event_handler
authorZhihao Yuan <zy@miator.net>
Tue, 27 Aug 2024 01:48:36 +0000 (18:48 -0700)
committerTomas Mraz <tomas@openssl.org>
Thu, 5 Sep 2024 15:20:43 +0000 (17:20 +0200)
Fixes #25278

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25300)

(cherry picked from commit 36840ab577d547a35cbc7c72396dc7931712eb6e)

crypto/initthread.c

index ae234cd205e5cdcaf3aef41a7e938b9637a5370a..cd59185fa439cb62c8d3eb8cf9be3286e9deb167 100644 (file)
@@ -266,9 +266,8 @@ void *ossl_thread_event_ctx_new(OSSL_LIB_CTX *libctx)
     if (tlocal == NULL)
         return NULL;
 
-    if (!CRYPTO_THREAD_init_local(tlocal, NULL)) {
-        goto err;
-    }
+    if (!CRYPTO_THREAD_init_local(tlocal, NULL))
+        goto deinit;
 
     hands = OPENSSL_zalloc(sizeof(*hands));
     if (hands == NULL)
@@ -290,12 +289,15 @@ void *ossl_thread_event_ctx_new(OSSL_LIB_CTX *libctx)
     return tlocal;
  err:
     OPENSSL_free(hands);
+    CRYPTO_THREAD_cleanup_local(tlocal);
+ deinit:
     OPENSSL_free(tlocal);
     return NULL;
 }
 
 void ossl_thread_event_ctx_free(void *tlocal)
 {
+    CRYPTO_THREAD_cleanup_local(tlocal);
     OPENSSL_free(tlocal);
 }