Commit fff9955fa0 for openssl.org
commit fff9955fa0c45ae2ba8afaa5c4bd6b366be915cd
Author: Aditya Patil <adityapatil.id@gmail.com>
Date: Fri Mar 20 10:43:10 2026 -0400
threadstest: Check the return value of two memory allocations
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)
diff --git a/test/threadstest.c b/test/threadstest.c
index 7167bbc223..f1c78373fb 100644
--- a/test/threadstest.c
+++ b/test/threadstest.c
@@ -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);