From: Jiasheng Jiang Date: Mon, 24 Jan 2022 03:06:34 +0000 (+0800) Subject: evp_test: Add the missing check after calling OPENSSL_malloc X-Git-Tag: openssl-3.2.0-alpha1~3027 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2208ba56ebefe4cf7d924e2ac7044ccd3307250b;p=thirdparty%2Fopenssl.git evp_test: Add the missing check after calling OPENSSL_malloc The OPENSSL_zalloc() could return NULL pointer if fails. Add the check for it does make sense, like how digest_test_init() deals with. CLA: trivial Signed-off-by: Jiasheng Jiang Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/17571) --- diff --git a/test/evp_test.c b/test/evp_test.c index 871f2a9c6bb..34caec2c5d9 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -588,7 +588,9 @@ static int cipher_test_init(EVP_TEST *t, const char *alg) } ERR_clear_last_mark(); - cdat = OPENSSL_zalloc(sizeof(*cdat)); + if (!TEST_ptr(cdat = OPENSSL_zalloc(sizeof(*cdat)))) + return 0; + cdat->cipher = cipher; cdat->fetched_cipher = fetched_cipher; cdat->enc = -1; @@ -1195,7 +1197,9 @@ static int mac_test_init(EVP_TEST *t, const char *alg) return 0; } - mdat = OPENSSL_zalloc(sizeof(*mdat)); + if (!TEST_ptr(mdat = OPENSSL_zalloc(sizeof(*mdat)))) + return 0; + mdat->type = type; mdat->mac_name = OPENSSL_strdup(alg); mdat->mac = mac;