diff options
author | Jiasheng Jiang <jiasheng@iscas.ac.cn> | 2022-01-24 11:06:34 +0800 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-01-25 18:15:22 +0100 |
commit | 2208ba56ebefe4cf7d924e2ac7044ccd3307250b (patch) | |
tree | aca08b0300673561cc42a657588af5004f4e6d8c /test/evp_test.c | |
parent | 954f45ba4c504570206ff5bed811e512cf92dc8e (diff) | |
download | openssl-new-2208ba56ebefe4cf7d924e2ac7044ccd3307250b.tar.gz |
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 <jiasheng@iscas.ac.cn>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17571)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index 871f2a9c6b..34caec2c5d 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; |