]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
cmp: add null pointer check in tear_down test function
authorPauli <pauli@openssl.org>
Wed, 11 Oct 2023 21:46:19 +0000 (08:46 +1100)
committerTomas Mraz <tomas@openssl.org>
Fri, 13 Oct 2023 15:35:45 +0000 (17:35 +0200)
problem reported by: 2ourc3

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22355)

(cherry picked from commit 91a5c0e40cf272d18b65c9e4c9a0268f244758a8)

test/cmp_protect_test.c

index 32dae32d9398d9803e472b91b2c698950debb923..09bf2ec17faffa0911b9c2d204af2d2f8858ff85 100644 (file)
@@ -37,15 +37,17 @@ static OSSL_PROVIDER *default_null_provider = NULL, *provider = NULL;
 
 static void tear_down(CMP_PROTECT_TEST_FIXTURE *fixture)
 {
-    OSSL_CMP_CTX_free(fixture->cmp_ctx);
-    OSSL_CMP_MSG_free(fixture->msg);
-    OSSL_CMP_PKISI_free(fixture->si);
+    if (fixture != NULL) {
+        OSSL_CMP_CTX_free(fixture->cmp_ctx);
+        OSSL_CMP_MSG_free(fixture->msg);
+        OSSL_CMP_PKISI_free(fixture->si);
 
-    OPENSSL_free(fixture->mem);
-    sk_X509_free(fixture->certs);
-    sk_X509_free(fixture->chain);
+        OPENSSL_free(fixture->mem);
+        sk_X509_free(fixture->certs);
+        sk_X509_free(fixture->chain);
 
-    OPENSSL_free(fixture);
+        OPENSSL_free(fixture);
+    }
 }
 
 static CMP_PROTECT_TEST_FIXTURE *set_up(const char *const test_case_name)