]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix potential memory leak in policy_section()
authorNiels Dossche <niels.dossche@ugent.be>
Tue, 21 Jan 2025 11:04:44 +0000 (12:04 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 25 Feb 2025 14:52:13 +0000 (15:52 +0100)
If sk_POLICYQUALINFO_push() fails, qual is not freed.
Fix it by adding POLICYQUALINFO_free() to the error path.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26499)

crypto/x509/v3_cpols.c

index ae602ea2cd28a00b39fcfcda692930da68a75b52..603bb1ce59813f5d39c591453f52d0b841871c59 100644 (file)
@@ -195,6 +195,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
                 goto err;
             }
             if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) {
+                POLICYQUALINFO_free(qual);
                 ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
                 goto err;
             }
@@ -232,6 +233,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx,
             if (pol->qualifiers == NULL)
                 pol->qualifiers = sk_POLICYQUALINFO_new_null();
             if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) {
+                POLICYQUALINFO_free(qual);
                 ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
                 goto err;
             }