Skip to content

Commit

Permalink
Fix memory leak on failure in copy_issuer()
Browse files Browse the repository at this point in the history
When sk_GENERAL_NAME_reserve() fails, ialt is not freed.
Add the freeing operation in the common error path.

Reviewed-by: Tom Cosgrove <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#25876)
  • Loading branch information
nielsdos authored and t8m committed Nov 7, 2024
1 parent 83b62d4 commit fa856b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/x509/v3_san.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -370,6 +370,7 @@ static int copy_issuer(X509V3_CTX *ctx, GENERAL_NAMES *gens)
return 1;

err:
sk_GENERAL_NAME_free(ialt);
return 0;

}
Expand Down

0 comments on commit fa856b0

Please sign in to comment.