diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-30 11:30:03 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-30 11:31:07 -0400 |
commit | 2ace745022f5af0709297e96eb0b0829c87c4291 (patch) | |
tree | 4352672cd8681d1df32edd39443c50a98fe0b065 /crypto/cms | |
parent | 5a80d9fbfe445420ffe6b649f29e2e0c412aba5d (diff) |
free NULL cleanup 8
Do not check for NULL before calling a free routine. This addresses:
ASN1_BIT_STRING_free ASN1_GENERALIZEDTIME_free ASN1_INTEGER_free
ASN1_OBJECT_free ASN1_OCTET_STRING_free ASN1_PCTX_free ASN1_SCTX_free
ASN1_STRING_clear_free ASN1_STRING_free ASN1_TYPE_free
ASN1_UTCTIME_free M_ASN1_free_of
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/cms')
-rw-r--r-- | crypto/cms/cms_env.c | 6 | ||||
-rw-r--r-- | crypto/cms/cms_ess.c | 3 | ||||
-rw-r--r-- | crypto/cms/cms_lib.c | 15 | ||||
-rw-r--r-- | crypto/cms/cms_sd.c | 6 |
4 files changed, 10 insertions, 20 deletions
diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c index 3b4b930136..98c1fe0120 100644 --- a/crypto/cms/cms_env.c +++ b/crypto/cms/cms_env.c @@ -277,8 +277,7 @@ CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, merr: CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT, ERR_R_MALLOC_FAILURE); err: - if (ri) - M_ASN1_free_of(ri, CMS_RecipientInfo); + M_ASN1_free_of(ri, CMS_RecipientInfo); EVP_PKEY_free(pk); return NULL; @@ -616,8 +615,7 @@ CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, merr: CMSerr(CMS_F_CMS_ADD0_RECIPIENT_KEY, ERR_R_MALLOC_FAILURE); err: - if (ri) - M_ASN1_free_of(ri, CMS_RecipientInfo); + M_ASN1_free_of(ri, CMS_RecipientInfo); return NULL; } diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c index 8212560628..6d5fa90a06 100644 --- a/crypto/cms/cms_ess.c +++ b/crypto/cms/cms_ess.c @@ -340,8 +340,7 @@ int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms) err: if (rr) CMS_ReceiptRequest_free(rr); - if (rct) - M_ASN1_free_of(rct, CMS_Receipt); + M_ASN1_free_of(rct, CMS_Receipt); return r; diff --git a/crypto/cms/cms_lib.c b/crypto/cms/cms_lib.c index 6d2a0e8275..8525ff8cf6 100644 --- a/crypto/cms/cms_lib.c +++ b/crypto/cms/cms_lib.c @@ -314,10 +314,8 @@ int CMS_set_detached(CMS_ContentInfo *cms, int detached) if (!pos) return 0; if (detached) { - if (*pos) { - ASN1_OCTET_STRING_free(*pos); - *pos = NULL; - } + ASN1_OCTET_STRING_free(*pos); + *pos = NULL; return 1; } if (!*pos) @@ -605,13 +603,11 @@ int cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert) goto err; if (!ASN1_STRING_copy(ias->serialNumber, X509_get_serialNumber(cert))) goto err; - if (*pias) - M_ASN1_free_of(*pias, CMS_IssuerAndSerialNumber); + M_ASN1_free_of(*pias, CMS_IssuerAndSerialNumber); *pias = ias; return 1; err: - if (ias) - M_ASN1_free_of(ias, CMS_IssuerAndSerialNumber); + M_ASN1_free_of(ias, CMS_IssuerAndSerialNumber); CMSerr(CMS_F_CMS_SET1_IAS, ERR_R_MALLOC_FAILURE); return 0; } @@ -629,8 +625,7 @@ int cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert) CMSerr(CMS_F_CMS_SET1_KEYID, ERR_R_MALLOC_FAILURE); return 0; } - if (*pkeyid) - ASN1_OCTET_STRING_free(*pkeyid); + ASN1_OCTET_STRING_free(*pkeyid); *pkeyid = keyid; return 1; } diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index 71c234cb39..c0a9780acf 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -404,8 +404,7 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, merr: CMSerr(CMS_F_CMS_ADD1_SIGNER, ERR_R_MALLOC_FAILURE); err: - if (si) - M_ASN1_free_of(si, CMS_SignerInfo); + M_ASN1_free_of(si, CMS_SignerInfo); return NULL; } @@ -904,8 +903,7 @@ int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs, } alg = X509_ALGOR_new(); if (!alg) { - if (key) - ASN1_INTEGER_free(key); + ASN1_INTEGER_free(key); return 0; } |