From: JAVAID Mohammad-Habib Date: Tue, 28 Feb 2023 20:07:59 +0000 (+0100) Subject: cmp_msg.c: free memory of certStatus before goto err X-Git-Tag: openssl-3.2.0-alpha1~1129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9c99018a887bfac1fe5a5ae6dcd8a5647494504;p=thirdparty%2Fopenssl.git cmp_msg.c: free memory of certStatus before goto err CLA: trivial Reviewed-by: David von Oheimb Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/20406) --- diff --git a/crypto/cmp/cmp_msg.c b/crypto/cmp/cmp_msg.c index 619cf7b78bf..64c83d6e34e 100644 --- a/crypto/cmp/cmp_msg.c +++ b/crypto/cmp/cmp_msg.c @@ -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;