From: Niels Dossche Date: Tue, 5 Nov 2024 15:11:56 +0000 (+0100) Subject: Fix memory leak on failure in copy_issuer() X-Git-Tag: openssl-3.5.0-alpha1~936 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa856b0ce0f527d2f80c10c8c288201ace4a9efa;p=thirdparty%2Fopenssl.git Fix memory leak on failure in copy_issuer() When sk_GENERAL_NAME_reserve() fails, ialt is not freed. Add the freeing operation in the common error path. Reviewed-by: Tom Cosgrove Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/25876) --- diff --git a/crypto/x509/v3_san.c b/crypto/x509/v3_san.c index dfcebc0a354..bc13c088d54 100644 --- a/crypto/x509/v3_san.c +++ b/crypto/x509/v3_san.c @@ -335,7 +335,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; @@ -370,6 +370,7 @@ static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens) return 1; err: + sk_GENERAL_NAME_free(ialt); return 0; }