From: Aditya Patil Date: Fri, 20 Mar 2026 14:43:10 +0000 (-0400) Subject: threadstest: Check the return value of two memory allocations X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fff9955fa0c45ae2ba8afaa5c4bd6b366be915cd;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Paul Dale 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 7167bbc223f..f1c78373fbb 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);