Skip to content

Commit

Permalink
Fix memory leak in X509V3_add1_i2d when flag is X509V3_ADD_DELETE
Browse files Browse the repository at this point in the history
Fixes #18677

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #18698)

(cherry picked from commit 4798e06)
  • Loading branch information
allanchang96 authored and t8m committed Jul 11, 2022
1 parent 174954c commit c340dfa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crypto/x509/v3_lib.c
Expand Up @@ -242,8 +242,10 @@ int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,
}
/* If delete, just delete it */
if (ext_op == X509V3_ADD_DELETE) {
if (!sk_X509_EXTENSION_delete(*x, extidx))
extmp = sk_X509_EXTENSION_delete(*x, extidx);
if (extmp == NULL)
return -1;
X509_EXTENSION_free(extmp);
return 1;
}
} else {
Expand Down

0 comments on commit c340dfa

Please sign in to comment.