Skip to content

Commit

Permalink
fixup! X509_add_cert(): prevent double free on X509_up_ref() failure
Browse files Browse the repository at this point in the history
  • Loading branch information
DDvO committed Oct 8, 2023
1 parent 26aea6f commit c7c6983
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/x509/x509_cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ int X509_add_cert(STACK_OF(X509) *sk, X509 *cert, int flags)
return 0;
if (!sk_X509_insert(sk, cert,
(flags & X509_ADD_FLAG_PREPEND) != 0 ? 0 : -1)) {
X509_free(cert);
if ((flags & X509_ADD_FLAG_UP_REF) != 0)
X509_free(cert);
ERR_raise(ERR_LIB_X509, ERR_R_CRYPTO_LIB);
return 0;
}
Expand Down

0 comments on commit c7c6983

Please sign in to comment.