]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
cmp_msg.c: free memory of certStatus before goto err
authorJAVAID Mohammad-Habib <mohammad-habib.javaid@etud.univ-paris8.fr>
Tue, 28 Feb 2023 20:07:59 +0000 (21:07 +0100)
committerTomas Mraz <tomas@openssl.org>
Mon, 20 Mar 2023 18:02:44 +0000 (19:02 +0100)
CLA: trivial

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20406)

crypto/cmp/cmp_msg.c

index 619cf7b78bf0d66da0faa145a90fa633bd3ebf20..64c83d6e34e75e4d4775da2dd56ab5bae84bb4d8 100644 (file)
@@ -817,8 +817,10 @@ OSSL_CMP_MSG *ossl_cmp_certConf_new(OSSL_CMP_CTX *ctx, int fail_info,
     if ((certStatus = OSSL_CMP_CERTSTATUS_new()) == NULL)
         goto err;
     /* consume certStatus into msg right away so it gets deallocated with msg */
-    if (!sk_OSSL_CMP_CERTSTATUS_push(msg->body->value.certConf, certStatus))
+    if (sk_OSSL_CMP_CERTSTATUS_push(msg->body->value.certConf, certStatus) < 1) {
+        OSSL_CMP_CERTSTATUS_free(certStatus);
         goto err;
+    }
     /* set the ID of the certReq */
     if (!ASN1_INTEGER_set(certStatus->certReqId, OSSL_CMP_CERTREQID))
         goto err;