summaryrefslogtreecommitdiffstats
path: root/crypto/rsa
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-05-01 10:02:07 -0400
committerRich Salz <rsalz@openssl.org>2015-05-01 10:02:07 -0400
commitb548a1f11c06ccdfa4f52a539912d22d77ee309e (patch)
tree37ff8792ddf09e4805aa3ba76b805923d3c52734 /crypto/rsa
parent33fbca83dcd05b77f807fab205c4523b8cfe85b5 (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/rsa')
-rw-r--r--crypto/rsa/rsa_ameth.c3
-rw-r--r--crypto/rsa/rsa_oaep.c6
-rw-r--r--crypto/rsa/rsa_pk1.c3
-rw-r--r--crypto/rsa/rsa_pmeth.c12
-rw-r--r--crypto/rsa/rsa_pss.c6
5 files changed, 10 insertions, 20 deletions
diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c
index 38b850ae7a..9313c93d68 100644
--- a/crypto/rsa/rsa_ameth.c
+++ b/crypto/rsa/rsa_ameth.c
@@ -251,8 +251,7 @@ static int do_rsa_print(BIO *bp, const RSA *x, int off, int priv)
}
ret = 1;
err:
- if (m != NULL)
- OPENSSL_free(m);
+ OPENSSL_free(m);
return (ret);
}
diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c
index ab8f9ec078..d988d6c217 100644
--- a/crypto/rsa/rsa_oaep.c
+++ b/crypto/rsa/rsa_oaep.c
@@ -232,10 +232,8 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1,
RSA_R_OAEP_DECODING_ERROR);
cleanup:
- if (db != NULL)
- OPENSSL_free(db);
- if (em != NULL)
- OPENSSL_free(em);
+ OPENSSL_free(db);
+ OPENSSL_free(em);
return mlen;
}
diff --git a/crypto/rsa/rsa_pk1.c b/crypto/rsa/rsa_pk1.c
index efa1fd3e99..1bda998ca4 100644
--- a/crypto/rsa/rsa_pk1.c
+++ b/crypto/rsa/rsa_pk1.c
@@ -266,8 +266,7 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
memcpy(to, em + msg_index, mlen);
err:
- if (em != NULL)
- OPENSSL_free(em);
+ OPENSSL_free(em);
if (mlen == -1)
RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2,
RSA_R_PKCS_DECODING_ERROR);
diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c
index 866dd1601e..94dc40881d 100644
--- a/crypto/rsa/rsa_pmeth.c
+++ b/crypto/rsa/rsa_pmeth.c
@@ -136,8 +136,7 @@ static int pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
dctx->md = sctx->md;
dctx->mgf1md = sctx->mgf1md;
if (sctx->oaep_label) {
- if (dctx->oaep_label)
- OPENSSL_free(dctx->oaep_label);
+ OPENSSL_free(dctx->oaep_label);
dctx->oaep_label = BUF_memdup(sctx->oaep_label, sctx->oaep_labellen);
if (!dctx->oaep_label)
return 0;
@@ -161,10 +160,8 @@ static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx)
RSA_PKEY_CTX *rctx = ctx->data;
if (rctx) {
BN_free(rctx->pub_exp);
- if (rctx->tbuf)
- OPENSSL_free(rctx->tbuf);
- if (rctx->oaep_label)
- OPENSSL_free(rctx->oaep_label);
+ OPENSSL_free(rctx->tbuf);
+ OPENSSL_free(rctx->oaep_label);
OPENSSL_free(rctx);
}
}
@@ -514,8 +511,7 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_PADDING_MODE);
return -2;
}
- if (rctx->oaep_label)
- OPENSSL_free(rctx->oaep_label);
+ OPENSSL_free(rctx->oaep_label);
if (p2 && p1 > 0) {
rctx->oaep_label = p2;
rctx->oaep_labellen = p1;
diff --git a/crypto/rsa/rsa_pss.c b/crypto/rsa/rsa_pss.c
index 318f5b8264..b5055dee98 100644
--- a/crypto/rsa/rsa_pss.c
+++ b/crypto/rsa/rsa_pss.c
@@ -170,8 +170,7 @@ int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
ret = 1;
err:
- if (DB)
- OPENSSL_free(DB);
+ OPENSSL_free(DB);
EVP_MD_CTX_cleanup(&ctx);
return ret;
@@ -279,8 +278,7 @@ int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
ret = 1;
err:
- if (salt)
- OPENSSL_free(salt);
+ OPENSSL_free(salt);
return ret;