Skip to content

Commit

Permalink
CMS_add1_crl(): prevent double free on failure of CMS_add0_crl()
Browse files Browse the repository at this point in the history
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 #19199)
  • Loading branch information
DDvO committed Feb 24, 2023
1 parent ee58915 commit 6f9e531
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crypto/cms/cms_lib.c
Expand Up @@ -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)
Expand Down

0 comments on commit 6f9e531

Please sign in to comment.