]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: check for NULL returns better
authorPauli <pauli@openssl.org>
Fri, 25 Jun 2021 02:57:53 +0000 (12:57 +1000)
committerPauli <pauli@openssl.org>
Sat, 26 Jun 2021 01:33:52 +0000 (11:33 +1000)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

test/hmactest.c
test/params_test.c

index 7cb7fb635cecc02f7a6004e2a5dd3589fa8a943e..63954a1183c672c186db5ae117a5d9830b40a534 100644 (file)
@@ -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)
index 205c2deab0588888986672a586fa40e838279162..13cfb9d19ecbf87cc7b5ab2f59642d048b16fed9 100644 (file)
@@ -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;