]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Free hashtable prior to freeing atomic worker_lock
authorNeil Horman <nhorman@openssl.org>
Mon, 17 Feb 2025 15:13:32 +0000 (10:13 -0500)
committerTomas Mraz <tomas@openssl.org>
Tue, 18 Feb 2025 15:40:40 +0000 (16:40 +0100)
lhash_test uses a hashtable that may not be empty at the end of the test

Given that the free function frees the elements in the list and uses the
atomic worker_lock to do so, we need to free the hash table prior to
freeing the working lock to avoid the use of unallocated memory.

Fixes #26798

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26800)

(cherry picked from commit 1636ae1a9022bad2fd5cf20f45e2729a55e688b7)

test/lhash_test.c

index aa5504c248ad758a89b114419641d015f073bdba..193254b6a697a26f4612b0cdbeea483310b2b381 100644 (file)
@@ -710,9 +710,9 @@ shutdown:
 
 end_free:
     shutting_down = 1;
+    ossl_ht_free(m_ht);
     CRYPTO_THREAD_lock_free(worker_lock);
     CRYPTO_THREAD_lock_free(testrand_lock);
-    ossl_ht_free(m_ht);
 end:
     return ret;
 }