]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
threadstest: Check the return value of two memory allocations
authorAditya Patil <adityapatil.id@gmail.com>
Fri, 20 Mar 2026 14:43:10 +0000 (10:43 -0400)
committerTomas Mraz <tomas@openssl.foundation>
Tue, 24 Mar 2026 17:43:52 +0000 (18:43 +0100)
Add a NULL check with OPENSSL_assert() before dereferencing the allocated pointer.

Fixes #30017

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Mar 24 17:44:44 2026
(Merged from https://github.com/openssl/openssl/pull/30509)

test/threadstest.c

index 7167bbc223fd5f653f24909d6ada8b2643d65c47..f1c78373fbb615f10117b8e256a04398ef9384af 100644 (file)
@@ -125,7 +125,8 @@ static void rwwriter_fn(int id, int *iterations)
     t1 = ossl_time_now();
 
     for (count = 0;; count++) {
-        new = CRYPTO_zalloc(sizeof(int), NULL, 0);
+        new = OPENSSL_zalloc(sizeof(int));
+        OPENSSL_assert(new != NULL);
         if (contention == 0)
             OSSL_sleep(1000);
         if (!CRYPTO_THREAD_write_lock(rwtorturelock))
@@ -323,7 +324,8 @@ static void writer_fn(int id, int *iterations)
     t1 = ossl_time_now();
 
     for (count = 0;; count++) {
-        new = CRYPTO_malloc(sizeof(uint64_t), NULL, 0);
+        new = OPENSSL_zalloc(sizeof(uint64_t));
+        OPENSSL_assert(new != NULL);
         *new = (uint64_t)0xBAD;
         if (contention == 0)
             OSSL_sleep(1000);