]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix memory leak on failure in copy_issuer()
authorNiels Dossche <niels.dossche@ugent.be>
Tue, 5 Nov 2024 15:11:56 +0000 (16:11 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 7 Nov 2024 09:20:36 +0000 (10:20 +0100)
When sk_GENERAL_NAME_reserve() fails, ialt is not freed.
Add the freeing operation in the common error path.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25876)

(cherry picked from commit fa856b0ce0f527d2f80c10c8c288201ace4a9efa)

crypto/x509/v3_san.c

index 34ca16a6d72daeb11ada8d6472dddcd9adcf19d0..d4999f1fc6c7131f5e20340bda967cc5d76004b3 100644 (file)
@@ -336,7 +336,7 @@ static GENERAL_NAMES *v2i_issuer_alt(X509V3_EXT_METHOD *method,
 
 static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens)
 {
-    GENERAL_NAMES *ialt;
+    GENERAL_NAMES *ialt = NULL;
     GENERAL_NAME *gen;
     X509_EXTENSION *ext;
     int i, num;
@@ -371,6 +371,7 @@ static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens)
     return 1;
 
  err:
+    sk_GENERAL_NAME_free(ialt);
     return 0;
 
 }