From f06c5547605b1e400f95eafb77a42947e4d50b78 Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 25 Jun 2021 12:57:53 +1000 Subject: [PATCH] test: check for NULL returns better Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/15910) --- test/hmactest.c | 3 ++- test/params_test.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/hmactest.c b/test/hmactest.c index 7cb7fb635ce..63954a1183c 100644 --- a/test/hmactest.c +++ b/test/hmactest.c @@ -132,7 +132,8 @@ static int test_hmac_run(void) unsigned int len; int ret = 0; - ctx = HMAC_CTX_new(); + if (!TEST_ptr(ctx = HMAC_CTX_new())) + return 0; HMAC_CTX_reset(ctx); if (!TEST_ptr(ctx) diff --git a/test/params_test.c b/test/params_test.c index 205c2deab05..13cfb9d19ec 100644 --- a/test/params_test.c +++ b/test/params_test.c @@ -97,7 +97,10 @@ static void cleanup_object(void *vobj) static void *init_object(void) { - struct object_st *obj = OPENSSL_zalloc(sizeof(*obj)); + struct object_st *obj; + + if (!TEST_ptr(obj = OPENSSL_zalloc(sizeof(*obj)))) + return NULL; obj->p1 = p1_init; obj->p2 = p2_init; -- 2.47.2