diff options
author | Rich Salz <rsalz@openssl.org> | 2015-05-01 10:02:07 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-05-01 10:02:07 -0400 |
commit | b548a1f11c06ccdfa4f52a539912d22d77ee309e (patch) | |
tree | 37ff8792ddf09e4805aa3ba76b805923d3c52734 /crypto/ec | |
parent | 33fbca83dcd05b77f807fab205c4523b8cfe85b5 (diff) |
free null cleanup finale
Don't check for NULL before calling OPENSSL_free
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/ec')
-rw-r--r-- | crypto/ec/ec_ameth.c | 6 | ||||
-rw-r--r-- | crypto/ec/ec_asn1.c | 15 | ||||
-rw-r--r-- | crypto/ec/ec_lib.c | 14 | ||||
-rw-r--r-- | crypto/ec/ec_mult.c | 10 | ||||
-rw-r--r-- | crypto/ec/ec_pmeth.c | 6 | ||||
-rw-r--r-- | crypto/ec/eck_prn.c | 3 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp224.c | 9 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp256.c | 9 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp521.c | 9 | ||||
-rw-r--r-- | crypto/ec/ecp_nistz256.c | 22 |
10 files changed, 34 insertions, 69 deletions
diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 0554c209e5..1cc4d4003b 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -132,8 +132,7 @@ static int eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) ASN1_OBJECT_free(pval); else ASN1_STRING_free(pval); - if (penc) - OPENSSL_free(penc); + OPENSSL_free(penc); return 0; } @@ -503,8 +502,7 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) BN_free(pub_key); BN_free(order); BN_CTX_free(ctx); - if (buffer != NULL) - OPENSSL_free(buffer); + OPENSSL_free(buffer); return (ret); } diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index 5976a2fba3..c86f22e7d1 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -525,10 +525,8 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) ok = 1; err: - if (buffer_1) - OPENSSL_free(buffer_1); - if (buffer_2) - OPENSSL_free(buffer_2); + OPENSSL_free(buffer_1); + OPENSSL_free(buffer_2); BN_free(tmp_1); BN_free(tmp_2); return (ok); @@ -628,8 +626,7 @@ static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *group, if (!param) ECPARAMETERS_free(ret); BN_free(tmp); - if (buffer) - OPENSSL_free(buffer); + OPENSSL_free(buffer); return NULL; } @@ -840,8 +837,7 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params) /* extract seed (optional) */ if (params->curve->seed != NULL) { - if (ret->seed != NULL) - OPENSSL_free(ret->seed); + OPENSSL_free(ret->seed); if (!(ret->seed = OPENSSL_malloc(params->curve->seed->length))) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE); goto err; @@ -1193,8 +1189,7 @@ int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) } ok = 1; err: - if (buffer) - OPENSSL_free(buffer); + OPENSSL_free(buffer); if (priv_key) EC_PRIVATEKEY_free(priv_key); return (ok ? ret : 0); diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index 1f51f74aa9..02de91da91 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -232,8 +232,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) dest->asn1_form = src->asn1_form; if (src->seed) { - if (dest->seed) - OPENSSL_free(dest->seed); + OPENSSL_free(dest->seed); dest->seed = OPENSSL_malloc(src->seed_len); if (dest->seed == NULL) return 0; @@ -241,8 +240,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) return 0; dest->seed_len = src->seed_len; } else { - if (dest->seed) - OPENSSL_free(dest->seed); + OPENSSL_free(dest->seed); dest->seed = NULL; dest->seed_len = 0; } @@ -382,11 +380,9 @@ point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP size_t EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len) { - if (group->seed) { - OPENSSL_free(group->seed); - group->seed = NULL; - group->seed_len = 0; - } + OPENSSL_free(group->seed); + group->seed = NULL; + group->seed_len = 0; if (!len || !p) return 1; diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index b4723fb5d5..115bc4258b 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -555,10 +555,8 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, err: BN_CTX_free(new_ctx); EC_POINT_free(tmp); - if (wsize != NULL) - OPENSSL_free(wsize); - if (wNAF_len != NULL) - OPENSSL_free(wNAF_len); + OPENSSL_free(wsize); + OPENSSL_free(wNAF_len); if (wNAF != NULL) { signed char **w; @@ -573,9 +571,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, OPENSSL_free(val); } - if (val_sub != NULL) { - OPENSSL_free(val_sub); - } + OPENSSL_free(val_sub); return ret; } diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c index 5b3d197b69..ec27e23c68 100644 --- a/crypto/ec/ec_pmeth.c +++ b/crypto/ec/ec_pmeth.c @@ -148,8 +148,7 @@ static void pkey_ec_cleanup(EVP_PKEY_CTX *ctx) if (dctx) { EC_GROUP_free(dctx->gen_group); EC_KEY_free(dctx->co_key); - if (dctx->kdf_ukm) - OPENSSL_free(dctx->kdf_ukm); + OPENSSL_free(dctx->kdf_ukm); OPENSSL_free(dctx); } } @@ -359,8 +358,7 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) return 1; case EVP_PKEY_CTRL_EC_KDF_UKM: - if (dctx->kdf_ukm) - OPENSSL_free(dctx->kdf_ukm); + OPENSSL_free(dctx->kdf_ukm); dctx->kdf_ukm = p2; if (p2) dctx->kdf_ukmlen = p1; diff --git a/crypto/ec/eck_prn.c b/crypto/ec/eck_prn.c index 6eb529138a..7cdc485b2e 100644 --- a/crypto/ec/eck_prn.c +++ b/crypto/ec/eck_prn.c @@ -325,8 +325,7 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off) BN_free(order); BN_free(cofactor); BN_CTX_free(ctx); - if (buffer != NULL) - OPENSSL_free(buffer); + OPENSSL_free(buffer); return (ret); } diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c index fdcf450331..60a8d50925 100644 --- a/crypto/ec/ecp_nistp224.c +++ b/crypto/ec/ecp_nistp224.c @@ -1573,12 +1573,9 @@ int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r, BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); - if (secrets != NULL) - OPENSSL_free(secrets); - if (pre_comp != NULL) - OPENSSL_free(pre_comp); - if (tmp_felems != NULL) - OPENSSL_free(tmp_felems); + OPENSSL_free(secrets); + OPENSSL_free(pre_comp); + OPENSSL_free(tmp_felems); return ret; } diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index d03bf15d8c..c9f073b616 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -2193,12 +2193,9 @@ int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r, BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); - if (secrets != NULL) - OPENSSL_free(secrets); - if (pre_comp != NULL) - OPENSSL_free(pre_comp); - if (tmp_smallfelems != NULL) - OPENSSL_free(tmp_smallfelems); + OPENSSL_free(secrets); + OPENSSL_free(pre_comp); + OPENSSL_free(tmp_smallfelems); return ret; } diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index 1069214f6b..bdfd57662f 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -2021,12 +2021,9 @@ int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r, BN_CTX_end(ctx); EC_POINT_free(generator); BN_CTX_free(new_ctx); - if (secrets != NULL) - OPENSSL_free(secrets); - if (pre_comp != NULL) - OPENSSL_free(pre_comp); - if (tmp_felems != NULL) - OPENSSL_free(tmp_felems); + OPENSSL_free(secrets); + OPENSSL_free(pre_comp); + OPENSSL_free(tmp_felems); return ret; } diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c index ae1fcddc10..e73d26cf7d 100644 --- a/crypto/ec/ecp_nistz256.c +++ b/crypto/ec/ecp_nistz256.c @@ -721,12 +721,9 @@ __owur static int ecp_nistz256_windowed_mul(const EC_GROUP *group, ret = 1; err: - if (table_storage) - OPENSSL_free(table_storage); - if (p_str) - OPENSSL_free(p_str); - if (scalars) - OPENSSL_free(scalars); + OPENSSL_free(table_storage); + OPENSSL_free(p_str); + OPENSSL_free(scalars); return ret; } @@ -889,8 +886,7 @@ __owur static int ecp_nistz256_mult_precompute(EC_GROUP *group, BN_CTX *ctx) BN_CTX_free(new_ctx); ecp_nistz256_pre_comp_free(pre_comp); - if (precomp_storage) - OPENSSL_free(precomp_storage); + OPENSSL_free(precomp_storage); EC_POINT_free(P); EC_POINT_free(T); return ret; @@ -1356,10 +1352,8 @@ err: if (ctx) BN_CTX_end(ctx); BN_CTX_free(new_ctx); - if (new_points) - OPENSSL_free(new_points); - if (new_scalars) - OPENSSL_free(new_scalars); + OPENSSL_free(new_points); + OPENSSL_free(new_scalars); return ret; } @@ -1451,9 +1445,7 @@ static void ecp_nistz256_pre_comp_free(void *pre_) if (i > 0) return; - if (pre->precomp_storage) - OPENSSL_free(pre->precomp_storage); - + OPENSSL_free(pre->precomp_storage); OPENSSL_free(pre); } |