diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-11 16:32:54 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-11 16:32:54 -0400 |
commit | e0e920b1a063f14f36418f8795c96f2c649400e1 (patch) | |
tree | b1704b3c1e380e01ab8fce7806bbd8d1d6997fa2 /crypto | |
parent | a38537721dfdd853c40b4b4d99b57950075b0178 (diff) |
free NULL cleanup 9
Ongoing work to skip NULL check before calling free routine. This gets:
ecp_nistz256_pre_comp_free nistp224_pre_comp_free nistp256_pre_comp_free
nistp521_pre_comp_free PKCS7_free PKCS7_RECIP_INFO_free
PKCS7_SIGNER_INFO_free sk_PKCS7_pop_free PKCS8_PRIV_KEY_INFO_free
PKCS12_free PKCS12_SAFEBAG_free PKCS12_free sk_PKCS12_SAFEBAG_pop_free
SSL_CONF_CTX_free SSL_CTX_free SSL_SESSION_free SSL_free ssl_cert_free
ssl_sess_cert_free
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ec/ecp_nistp224.c | 3 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp256.c | 3 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp521.c | 3 | ||||
-rw-r--r-- | crypto/ec/ecp_nistz256.c | 3 | ||||
-rw-r--r-- | crypto/pkcs12/p12_crt.c | 25 | ||||
-rw-r--r-- | crypto/pkcs12/p12_init.c | 5 | ||||
-rw-r--r-- | crypto/pkcs7/pk7_lib.c | 15 |
7 files changed, 17 insertions, 40 deletions
diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c index 2f1213f1f7..76adc8a6d1 100644 --- a/crypto/ec/ecp_nistp224.c +++ b/crypto/ec/ecp_nistp224.c @@ -1741,8 +1741,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx) EC_POINT_free(generator); if (new_ctx != NULL) BN_CTX_free(new_ctx); - if (pre) - nistp224_pre_comp_free(pre); + nistp224_pre_comp_free(pre); return ret; } diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index 9ec034669a..794520e99a 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -2342,8 +2342,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx) EC_POINT_free(generator); if (new_ctx != NULL) BN_CTX_free(new_ctx); - if (pre) - nistp256_pre_comp_free(pre); + nistp256_pre_comp_free(pre); return ret; } diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index c8f9d1e78d..7ceb1bcbfa 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -2125,8 +2125,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx) EC_POINT_free(generator); if (new_ctx != NULL) BN_CTX_free(new_ctx); - if (pre) - nistp521_pre_comp_free(pre); + nistp521_pre_comp_free(pre); return ret; } diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c index ea692b81ef..de9fbea515 100644 --- a/crypto/ec/ecp_nistz256.c +++ b/crypto/ec/ecp_nistz256.c @@ -870,8 +870,7 @@ static int ecp_nistz256_mult_precompute(EC_GROUP *group, BN_CTX *ctx) err: if (ctx != NULL) BN_CTX_end(ctx); - if (pre_comp) - ecp_nistz256_pre_comp_free(pre_comp); + ecp_nistz256_pre_comp_free(pre_comp); if (precomp_storage) OPENSSL_free(precomp_storage); EC_POINT_free(P); diff --git a/crypto/pkcs12/p12_crt.c b/crypto/pkcs12/p12_crt.c index 1b2e889eaf..fcc77cd2fc 100644 --- a/crypto/pkcs12/p12_crt.c +++ b/crypto/pkcs12/p12_crt.c @@ -173,13 +173,9 @@ PKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert, return p12; err: - - if (p12) - PKCS12_free(p12); - if (safes) - sk_PKCS7_pop_free(safes, PKCS7_free); - if (bags) - sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); + PKCS12_free(p12); + sk_PKCS7_pop_free(safes, PKCS7_free); + sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); return NULL; } @@ -216,10 +212,7 @@ PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert) return bag; err: - - if (bag) - PKCS12_SAFEBAG_free(bag); - + PKCS12_SAFEBAG_free(bag); return NULL; } @@ -252,10 +245,7 @@ PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, return bag; err: - - if (bag) - PKCS12_SAFEBAG_free(bag); - + PKCS12_SAFEBAG_free(bag); return NULL; } @@ -298,10 +288,7 @@ int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, sk_PKCS7_free(*psafes); *psafes = NULL; } - - if (p7) - PKCS7_free(p7); - + PKCS7_free(p7); return 0; } diff --git a/crypto/pkcs12/p12_init.c b/crypto/pkcs12/p12_init.c index 34710e9e69..22fa10e865 100644 --- a/crypto/pkcs12/p12_init.c +++ b/crypto/pkcs12/p12_init.c @@ -83,10 +83,9 @@ PKCS12 *PKCS12_init(int mode) PKCS12err(PKCS12_F_PKCS12_INIT, PKCS12_R_UNSUPPORTED_PKCS12_MODE); goto err; } - return pkcs12; + err: - if (pkcs12 != NULL) - PKCS12_free(pkcs12); + PKCS12_free(pkcs12); return NULL; } diff --git a/crypto/pkcs7/pk7_lib.c b/crypto/pkcs7/pk7_lib.c index 956f3f22e7..e14d8c6c3c 100644 --- a/crypto/pkcs7/pk7_lib.c +++ b/crypto/pkcs7/pk7_lib.c @@ -121,8 +121,7 @@ int PKCS7_content_new(PKCS7 *p7, int type) return (1); err: - if (ret != NULL) - PKCS7_free(ret); + PKCS7_free(ret); return (0); } @@ -133,13 +132,11 @@ int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data) i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: - if (p7->d.sign->contents != NULL) - PKCS7_free(p7->d.sign->contents); + PKCS7_free(p7->d.sign->contents); p7->d.sign->contents = p7_data; break; case NID_pkcs7_digest: - if (p7->d.digest->contents != NULL) - PKCS7_free(p7->d.digest->contents); + PKCS7_free(p7->d.digest->contents); p7->d.digest->contents = p7_data; break; case NID_pkcs7_data: @@ -422,8 +419,7 @@ PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, goto err; return (si); err: - if (si) - PKCS7_SIGNER_INFO_free(si); + PKCS7_SIGNER_INFO_free(si); return (NULL); } @@ -484,8 +480,7 @@ PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509) goto err; return ri; err: - if (ri) - PKCS7_RECIP_INFO_free(ri); + PKCS7_RECIP_INFO_free(ri); return NULL; } |