CMS_add1_crl(): prevent double free on failure of CMS_add0_crl()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/19199)
This commit is contained in:
Dr. David von Oheimb 2023-02-10 09:53:43 +01:00 committed by Dr. David von Oheimb
parent ee58915cfd
commit 6f9e531003

View File

@ -620,11 +620,12 @@ int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl)
int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl)
{
int r;
r = CMS_add0_crl(cms, crl);
if (r > 0)
X509_CRL_up_ref(crl);
return r;
if (!X509_CRL_up_ref(crl))
return 0;
if (CMS_add0_crl(cms, crl))
return 1;
X509_CRL_free(crl);
return 0;
}
STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms)