summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-05-01 16:02:07 +0200
committerRich Salz <rsalz@openssl.org>2015-05-01 16:02:07 +0200
commitb548a1f11c06ccdfa4f52a539912d22d77ee309e (patch)
tree37ff8792ddf09e4805aa3ba76b805923d3c52734 /crypto
parentFix some typo's, silence warnings. (diff)
downloadopenssl-b548a1f11c06ccdfa4f52a539912d22d77ee309e.tar.xz
openssl-b548a1f11c06ccdfa4f52a539912d22d77ee309e.zip
free null cleanup finale
Don't check for NULL before calling OPENSSL_free Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/asn1/a_bitstr.c3
-rw-r--r--crypto/asn1/a_enum.c3
-rw-r--r--crypto/asn1/a_gentm.c3
-rw-r--r--crypto/asn1/a_int.c9
-rw-r--r--crypto/asn1/a_mbstr.c8
-rw-r--r--crypto/asn1/a_object.c12
-rw-r--r--crypto/asn1/a_sign.c6
-rw-r--r--crypto/asn1/a_utctm.c3
-rw-r--r--crypto/asn1/ameth_lib.c6
-rw-r--r--crypto/asn1/asn1_gen.c9
-rw-r--r--crypto/asn1/asn1_lib.c5
-rw-r--r--crypto/asn1/asn_mime.c30
-rw-r--r--crypto/asn1/asn_pack.c6
-rw-r--r--crypto/asn1/bio_asn1.c3
-rw-r--r--crypto/asn1/bio_ndef.c6
-rw-r--r--crypto/asn1/f_enum.c3
-rw-r--r--crypto/asn1/f_int.c3
-rw-r--r--crypto/asn1/f_string.c3
-rw-r--r--crypto/asn1/t_x509.c6
-rw-r--r--crypto/asn1/tasn_dec.c5
-rw-r--r--crypto/asn1/tasn_prn.c3
-rw-r--r--crypto/asn1/tasn_scn.c3
-rw-r--r--crypto/asn1/tasn_utl.c6
-rw-r--r--crypto/asn1/x_info.c3
-rw-r--r--crypto/asn1/x_pkey.c2
-rw-r--r--crypto/asn1/x_pubkey.c3
-rw-r--r--crypto/asn1/x_x509.c7
-rw-r--r--crypto/bio/b_sock.c3
-rw-r--r--crypto/bio/bf_buff.c9
-rw-r--r--crypto/bio/bf_lbuf.c3
-rw-r--r--crypto/bio/bf_nbio.c3
-rw-r--r--crypto/bio/bss_acpt.c9
-rw-r--r--crypto/bio/bss_bio.c11
-rw-r--r--crypto/bio/bss_conn.c21
-rw-r--r--crypto/bio/bss_dgram.c9
-rw-r--r--crypto/bn/bn_exp.c3
-rw-r--r--crypto/bn/bn_gf2m.c15
-rw-r--r--crypto/bn/bn_intern.c14
-rw-r--r--crypto/bn/bn_lib.c5
-rw-r--r--crypto/bn/bn_print.c13
-rw-r--r--crypto/bn/bn_rand.c3
-rw-r--r--crypto/cms/cms_env.c9
-rw-r--r--crypto/cms/cms_ess.c3
-rw-r--r--crypto/cms/cms_kari.c5
-rw-r--r--crypto/cms/cms_pwri.c2
-rw-r--r--crypto/cms/cms_sd.c3
-rw-r--r--crypto/comp/c_zlib.c15
-rw-r--r--crypto/conf/conf_api.c3
-rw-r--r--crypto/conf/conf_def.c18
-rw-r--r--crypto/conf/conf_mod.c6
-rw-r--r--crypto/dh/dh_ameth.c17
-rw-r--r--crypto/dh/dh_kdf.c3
-rw-r--r--crypto/dh/dh_lib.c3
-rw-r--r--crypto/dh/dh_pmeth.c6
-rw-r--r--crypto/dsa/dsa_ameth.c12
-rw-r--r--crypto/dsa/dsa_gen.c3
-rw-r--r--crypto/dsa/dsa_pmeth.c3
-rw-r--r--crypto/dso/dso_dl.c3
-rw-r--r--crypto/dso/dso_dlfcn.c3
-rw-r--r--crypto/dso/dso_lib.c10
-rw-r--r--crypto/dso/dso_vms.c6
-rw-r--r--crypto/dso/dso_win32.c6
-rw-r--r--crypto/ec/ec_ameth.c6
-rw-r--r--crypto/ec/ec_asn1.c15
-rw-r--r--crypto/ec/ec_lib.c14
-rw-r--r--crypto/ec/ec_mult.c10
-rw-r--r--crypto/ec/ec_pmeth.c6
-rw-r--r--crypto/ec/eck_prn.c3
-rw-r--r--crypto/ec/ecp_nistp224.c9
-rw-r--r--crypto/ec/ecp_nistp256.c9
-rw-r--r--crypto/ec/ecp_nistp521.c9
-rw-r--r--crypto/ec/ecp_nistz256.c22
-rw-r--r--crypto/ecdh/ech_ossl.c3
-rw-r--r--crypto/engine/eng_cryptodev.c8
-rw-r--r--crypto/engine/eng_dyn.c19
-rw-r--r--crypto/err/err.c3
-rw-r--r--crypto/evp/evp_enc.c6
-rw-r--r--crypto/ex_data.c9
-rw-r--r--crypto/mem.c3
-rw-r--r--crypto/objects/obj_dat.c9
-rw-r--r--crypto/objects/obj_lib.c12
-rw-r--r--crypto/ocsp/ocsp_ext.c3
-rw-r--r--crypto/ocsp/ocsp_ht.c3
-rw-r--r--crypto/ocsp/ocsp_lib.c12
-rw-r--r--crypto/pem/pem_info.c18
-rw-r--r--crypto/pem/pem_seal.c6
-rw-r--r--crypto/pem/pem_sign.c3
-rw-r--r--crypto/pem/pvkfmt.c5
-rw-r--r--crypto/pkcs7/pk7_doit.c8
-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
-rw-r--r--crypto/stack/stack.c6
-rw-r--r--crypto/store/str_mem.c3
-rw-r--r--crypto/threads/th-lock.c6
-rw-r--r--crypto/txt_db/txt_db.c18
-rw-r--r--crypto/ui/ui_lib.c12
-rw-r--r--crypto/x509/by_dir.c3
-rw-r--r--crypto/x509/x509_vpm.c26
-rw-r--r--crypto/x509/x509spki.c6
-rw-r--r--crypto/x509/x_name.c9
-rw-r--r--crypto/x509v3/v3_conf.c6
-rw-r--r--crypto/x509v3/v3_prn.c3
-rw-r--r--crypto/x509v3/v3_scts.c3
-rw-r--r--crypto/x509v3/v3_utl.c24
107 files changed, 273 insertions, 534 deletions
diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c
index ba243f1a5f..60b6e6d403 100644
--- a/crypto/asn1/a_bitstr.c
+++ b/crypto/asn1/a_bitstr.c
@@ -168,8 +168,7 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
s = NULL;
ret->length = (int)len;
- if (ret->data != NULL)
- OPENSSL_free(ret->data);
+ OPENSSL_free(ret->data);
ret->data = s;
ret->type = V_ASN1_BIT_STRING;
if (a != NULL)
diff --git a/crypto/asn1/a_enum.c b/crypto/asn1/a_enum.c
index 54d6542cbe..4abd80c122 100644
--- a/crypto/asn1/a_enum.c
+++ b/crypto/asn1/a_enum.c
@@ -75,8 +75,7 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
a->type = V_ASN1_ENUMERATED;
if (a->length < (int)(sizeof(long) + 1)) {
- if (a->data != NULL)
- OPENSSL_free(a->data);
+ OPENSSL_free(a->data);
if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL)
memset((char *)a->data, 0, sizeof(long) + 1);
}
diff --git a/crypto/asn1/a_gentm.c b/crypto/asn1/a_gentm.c
index 0e9149a3ca..324496e30c 100644
--- a/crypto/asn1/a_gentm.c
+++ b/crypto/asn1/a_gentm.c
@@ -243,8 +243,7 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- if (s->data != NULL)
- OPENSSL_free(s->data);
+ OPENSSL_free(s->data);
s->data = (unsigned char *)p;
}
diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c
index b5246a65c3..68a312b97a 100644
--- a/crypto/asn1/a_int.c
+++ b/crypto/asn1/a_int.c
@@ -258,8 +258,7 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
memcpy(s, p, (int)len);
}
- if (ret->data != NULL)
- OPENSSL_free(ret->data);
+ OPENSSL_free(ret->data);
ret->data = s;
ret->length = (int)len;
if (a != NULL)
@@ -327,8 +326,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
p += len;
}
- if (ret->data != NULL)
- OPENSSL_free(ret->data);
+ OPENSSL_free(ret->data);
ret->data = s;
ret->length = (int)len;
if (a != NULL)
@@ -349,8 +347,7 @@ int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
unsigned char buf[sizeof(long) + 1];
if (a->length < (int)(sizeof(long) + 1)) {
- if (a->data != NULL)
- OPENSSL_free(a->data);
+ OPENSSL_free(a->data);
if ((a->data = OPENSSL_malloc(sizeof(long) + 1)) != NULL)
memset((char *)a->data, 0, sizeof(long) + 1);
}
diff --git a/crypto/asn1/a_mbstr.c b/crypto/asn1/a_mbstr.c
index 6935efe09f..2ff496b4fd 100644
--- a/crypto/asn1/a_mbstr.c
+++ b/crypto/asn1/a_mbstr.c
@@ -190,11 +190,9 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
if (*out) {
free_out = 0;
dest = *out;
- if (dest->data) {
- dest->length = 0;
- OPENSSL_free(dest->data);
- dest->data = NULL;
- }
+ OPENSSL_free(dest->data);
+ dest->data = NULL;
+ dest->length = 0;
dest->type = str_type;
} else {
free_out = 1;
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c
index 1e76122192..809e9a4112 100644
--- a/crypto/asn1/a_object.c
+++ b/crypto/asn1/a_object.c
@@ -313,8 +313,7 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
/* once detached we can change it */
if ((data == NULL) || (ret->length < length)) {
ret->length = 0;
- if (data != NULL)
- OPENSSL_free(data);
+ OPENSSL_free(data);
data = OPENSSL_malloc(length);
if (data == NULL) {
i = ERR_R_MALLOC_FAILURE;
@@ -368,16 +367,13 @@ void ASN1_OBJECT_free(ASN1_OBJECT *a)
#ifndef CONST_STRICT /* disable purely for compile-time strict
* const checking. Doing this on a "real"
* compile will cause memory leaks */
- if (a->sn != NULL)
- OPENSSL_free((void *)a->sn);
- if (a->ln != NULL)
- OPENSSL_free((void *)a->ln);
+ OPENSSL_free((void*)a->sn);
+ OPENSSL_free((void*)a->ln);
#endif
a->sn = a->ln = NULL;
}
if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) {
- if (a->data != NULL)
- OPENSSL_free((void *)a->data);
+ OPENSSL_free((void*)a->data);
a->data = NULL;
a->length = 0;
}
diff --git a/crypto/asn1/a_sign.c b/crypto/asn1/a_sign.c
index fb7536d84e..e189958174 100644
--- a/crypto/asn1/a_sign.c
+++ b/crypto/asn1/a_sign.c
@@ -190,8 +190,7 @@ int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, X509_ALGOR *algor2,
ASN1err(ASN1_F_ASN1_SIGN, ERR_R_EVP_LIB);
goto err;
}
- if (signature->data != NULL)
- OPENSSL_free(signature->data);
+ OPENSSL_free(signature->data);
signature->data = buf_out;
buf_out = NULL;
signature->length = outl;
@@ -300,8 +299,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB);
goto err;
}
- if (signature->data != NULL)
- OPENSSL_free(signature->data);
+ OPENSSL_free(signature->data);
signature->data = buf_out;
buf_out = NULL;
signature->length = outl;
diff --git a/crypto/asn1/a_utctm.c b/crypto/asn1/a_utctm.c
index 0e2f1b0c40..5fd1a6a3c4 100644
--- a/crypto/asn1/a_utctm.c
+++ b/crypto/asn1/a_utctm.c
@@ -218,8 +218,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
ASN1err(ASN1_F_ASN1_UTCTIME_ADJ, ERR_R_MALLOC_FAILURE);
goto err;
}
- if (s->data != NULL)
- OPENSSL_free(s->data);
+ OPENSSL_free(s->data);
s->data = (unsigned char *)p;
}
diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c
index 5c7d6bb207..718aa521c5 100644
--- a/crypto/asn1/ameth_lib.c
+++ b/crypto/asn1/ameth_lib.c
@@ -384,10 +384,8 @@ void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth)
{
if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) {
- if (ameth->pem_str)
- OPENSSL_free(ameth->pem_str);
- if (ameth->info)
- OPENSSL_free(ameth->info);
+ OPENSSL_free(ameth->pem_str);
+ OPENSSL_free(ameth->info);
OPENSSL_free(ameth);
}
}
diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c
index 3e066bc3e8..6756c67a47 100644
--- a/crypto/asn1/asn1_gen.c
+++ b/crypto/asn1/asn1_gen.c
@@ -280,10 +280,8 @@ static ASN1_TYPE *generate_v3(char *str, X509V3_CTX *cnf, int depth,
ret = d2i_ASN1_TYPE(NULL, &cp, len);
err:
- if (orig_der)
- OPENSSL_free(orig_der);
- if (new_der)
- OPENSSL_free(new_der);
+ OPENSSL_free(orig_der);
+ OPENSSL_free(new_der);
return ret;
@@ -510,8 +508,7 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
bad:
- if (der)
- OPENSSL_free(der);
+ OPENSSL_free(der);
sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
if (sect)
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index a892d7f063..e1e509b3ec 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -335,8 +335,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)
{
- if (str->data)
- OPENSSL_free(str->data);
+ OPENSSL_free(str->data);
str->data = data;
str->length = len;
}
@@ -366,7 +365,7 @@ void ASN1_STRING_free(ASN1_STRING *a)
{
if (a == NULL)
return;
- if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF))
+ if (!(a->flags & ASN1_STRING_FLAG_NDEF))
OPENSSL_free(a->data);
OPENSSL_free(a);
}
diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c
index 9b397aeaa0..e8411a82ad 100644
--- a/crypto/asn1/asn_mime.c
+++ b/crypto/asn1/asn_mime.c
@@ -854,12 +854,9 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
return mhdr;
err:
- if (tmpname != NULL)
- OPENSSL_free(tmpname);
- if (tmpval != NULL)
- OPENSSL_free(tmpval);
- if (mhdr != NULL)
- OPENSSL_free(mhdr);
+ OPENSSL_free(tmpname);
+ OPENSSL_free(tmpval);
+ OPENSSL_free(mhdr);
return NULL;
}
@@ -895,12 +892,9 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
goto err;
return 1;
err:
- if (tmpname != NULL)
- OPENSSL_free(tmpname);
- if (tmpval != NULL)
- OPENSSL_free(tmpval);
- if (mparam != NULL)
- OPENSSL_free(mparam);
+ OPENSSL_free(tmpname);
+ OPENSSL_free(tmpval);
+ OPENSSL_free(mparam);
return 0;
}
@@ -947,10 +941,8 @@ static MIME_PARAM *mime_param_find(MIME_HEADER *hdr, char *name)
static void mime_hdr_free(MIME_HEADER *hdr)
{
- if (hdr->name)
- OPENSSL_free(hdr->name);
- if (hdr->value)
- OPENSSL_free(hdr->value);
+ OPENSSL_free(hdr->name);
+ OPENSSL_free(hdr->value);
if (hdr->params)
sk_MIME_PARAM_pop_free(hdr->params, mime_param_free);
OPENSSL_free(hdr);
@@ -958,10 +950,8 @@ static void mime_hdr_free(MIME_HEADER *hdr)
static void mime_param_free(MIME_PARAM *param)
{
- if (param->param_name)
- OPENSSL_free(param->param_name);
- if (param->param_value)
- OPENSSL_free(param->param_value);
+ OPENSSL_free(param->param_name);
+ OPENSSL_free(param->param_value);
OPENSSL_free(param);
}
diff --git a/crypto/asn1/asn_pack.c b/crypto/asn1/asn_pack.c
index 8d0f0b091f..e358a8676f 100644
--- a/crypto/asn1/asn_pack.c
+++ b/crypto/asn1/asn_pack.c
@@ -77,10 +77,8 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
} else
octmp = *oct;
- if (octmp->data) {
- OPENSSL_free(octmp->data);
- octmp->data = NULL;
- }
+ OPENSSL_free(octmp->data);
+ octmp->data = NULL;
if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) {
ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR);
diff --git a/crypto/asn1/bio_asn1.c b/crypto/asn1/bio_asn1.c
index d4be23c190..ba39069374 100644
--- a/crypto/asn1/bio_asn1.c
+++ b/crypto/asn1/bio_asn1.c
@@ -183,8 +183,7 @@ static int asn1_bio_free(BIO *b)
if (ctx == NULL)
return 0;
- if (ctx->buf)
- OPENSSL_free(ctx->buf);
+ OPENSSL_free(ctx->buf);
OPENSSL_free(ctx);
b->init = 0;
b->ptr = NULL;
diff --git a/crypto/asn1/bio_ndef.c b/crypto/asn1/bio_ndef.c
index 99ab5f66e1..de517f22e4 100644
--- a/crypto/asn1/bio_ndef.c
+++ b/crypto/asn1/bio_ndef.c
@@ -143,8 +143,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
err:
BIO_free(asn_bio);
- if (ndef_aux)
- OPENSSL_free(ndef_aux);
+ OPENSSL_free(ndef_aux);
return NULL;
}
@@ -186,8 +185,7 @@ static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen,
ndef_aux = *(NDEF_SUPPORT **)parg;
- if (ndef_aux->derbuf)
- OPENSSL_free(ndef_aux->derbuf);
+ OPENSSL_free(ndef_aux->derbuf);
ndef_aux->derbuf = NULL;
*pbuf = NULL;
diff --git a/crypto/asn1/f_enum.c b/crypto/asn1/f_enum.c
index 2ec99a51a3..338a02e291 100644
--- a/crypto/asn1/f_enum.c
+++ b/crypto/asn1/f_enum.c
@@ -154,8 +154,7 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
- if (s != NULL)
- OPENSSL_free(s);
+ OPENSSL_free(s);
goto err;
}
s = sp;
diff --git a/crypto/asn1/f_int.c b/crypto/asn1/f_int.c
index f74252c45a..5a2d18b582 100644
--- a/crypto/asn1/f_int.c
+++ b/crypto/asn1/f_int.c
@@ -168,8 +168,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
- if (s != NULL)
- OPENSSL_free(s);
+ OPENSSL_free(s);
goto err;
}
s = sp;
diff --git a/crypto/asn1/f_string.c b/crypto/asn1/f_string.c
index 53f8cf3a83..e9dcee8e86 100644
--- a/crypto/asn1/f_string.c
+++ b/crypto/asn1/f_string.c
@@ -160,8 +160,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
sp = OPENSSL_realloc(s, (unsigned int)num + i * 2);
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE);
- if (s != NULL)
- OPENSSL_free(s);
+ OPENSSL_free(s);
goto err;
}
s = sp;
diff --git a/crypto/asn1/t_x509.c b/crypto/asn1/t_x509.c
index da73b6dfc8..c32f28efee 100644
--- a/crypto/asn1/t_x509.c
+++ b/crypto/asn1/t_x509.c
@@ -249,8 +249,7 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
}
ret = 1;
err:
- if (m != NULL)
- OPENSSL_free(m);
+ OPENSSL_free(m);
return (ret);
}
@@ -299,8 +298,7 @@ int X509_ocspid_print(BIO *bp, X509 *x)
return (1);
err:
- if (der != NULL)
- OPENSSL_free(der);
+ OPENSSL_free(der);
return (0);
}
diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c
index ef19fcdfae..c5caff7ddd 100644
--- a/crypto/asn1/tasn_dec.c
+++ b/crypto/asn1/tasn_dec.c
@@ -765,7 +765,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
*in = p;
ret = 1;
err:
- if (free_cont && buf.data)
+ if (free_cont)
OPENSSL_free(buf.data);
return ret;
}
@@ -882,8 +882,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
}
/* If we've already allocated a buffer use it */
if (*free_cont) {
- if (stmp->data)
- OPENSSL_free(stmp->data);
+ OPENSSL_free(stmp->data);
stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */
stmp->length = len;
*free_cont = 0;
diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c
index 10974eb7f4..76d584b2ba 100644
--- a/crypto/asn1/tasn_prn.c
+++ b/crypto/asn1/tasn_prn.c
@@ -100,8 +100,7 @@ ASN1_PCTX *ASN1_PCTX_new(void)
void ASN1_PCTX_free(ASN1_PCTX *p)
{
- if (p)
- OPENSSL_free(p);
+ OPENSSL_free(p);
}
unsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p)
diff --git a/crypto/asn1/tasn_scn.c b/crypto/asn1/tasn_scn.c
index 830540550e..cedea9cb78 100644
--- a/crypto/asn1/tasn_scn.c
+++ b/crypto/asn1/tasn_scn.c
@@ -86,8 +86,7 @@ ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx))
void ASN1_SCTX_free(ASN1_SCTX *p)
{
- if (p)
- OPENSSL_free(p);
+ OPENSSL_free(p);
}
const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p)
diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c
index 17318ea587..76e96051bf 100644
--- a/crypto/asn1/tasn_utl.c
+++ b/crypto/asn1/tasn_utl.c
@@ -154,8 +154,7 @@ void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
ASN1_ENCODING *enc;
enc = asn1_get_enc_ptr(pval, it);
if (enc) {
- if (enc->enc)
- OPENSSL_free(enc->enc);
+ OPENSSL_free(enc->enc);
enc->enc = NULL;
enc->len = 0;
enc->modified = 1;
@@ -170,8 +169,7 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
if (!enc)
return 1;
- if (enc->enc)
- OPENSSL_free(enc->enc);
+ OPENSSL_free(enc->enc);
enc->enc = OPENSSL_malloc(inlen);
if (!enc->enc)
return 0;
diff --git a/crypto/asn1/x_info.c b/crypto/asn1/x_info.c
index 4783fc48a9..5b927efc67 100644
--- a/crypto/asn1/x_info.c
+++ b/crypto/asn1/x_info.c
@@ -106,7 +106,6 @@ void X509_INFO_free(X509_INFO *x)
X509_free(x->x509);
X509_CRL_free(x->crl);
X509_PKEY_free(x->x_pkey);
- if (x->enc_data != NULL)
- OPENSSL_free(x->enc_data);
+ OPENSSL_free(x->enc_data);
OPENSSL_free(x);
}
diff --git a/crypto/asn1/x_pkey.c b/crypto/asn1/x_pkey.c
index fc5de8a96f..59e002bd45 100644
--- a/crypto/asn1/x_pkey.c
+++ b/crypto/asn1/x_pkey.c
@@ -113,7 +113,7 @@ void X509_PKEY_free(X509_PKEY *x)
X509_ALGOR_free(x->enc_algor);
ASN1_OCTET_STRING_free(x->enc_pkey);
EVP_PKEY_free(x->dec_pkey);
- if ((x->key_data != NULL) && (x->key_free))
+ if (x->key_free)
OPENSSL_free(x->key_data);
OPENSSL_free(x);
}
diff --git a/crypto/asn1/x_pubkey.c b/crypto/asn1/x_pubkey.c
index 158c24062e..2605f07013 100644
--- a/crypto/asn1/x_pubkey.c
+++ b/crypto/asn1/x_pubkey.c
@@ -340,8 +340,7 @@ int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
if (!X509_ALGOR_set0(pub->algor, aobj, ptype, pval))
return 0;
if (penc) {
- if (pub->public_key->data)
- OPENSSL_free(pub->public_key->data);
+ OPENSSL_free(pub->public_key->data);
pub->public_key->data = penc;
pub->public_key->length = penclen;
/* Set number of unused bits to zero */
diff --git a/crypto/asn1/x_x509.c b/crypto/asn1/x_x509.c
index 08bb4bd33c..1b353af844 100644
--- a/crypto/asn1/x_x509.c
+++ b/crypto/asn1/x_x509.c
@@ -103,8 +103,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
break;
case ASN1_OP_D2I_POST:
- if (ret->name != NULL)
- OPENSSL_free(ret->name);
+ OPENSSL_free(ret->name);
ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0);
break;
@@ -119,9 +118,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
NAME_CONSTRAINTS_free(ret->nc);
sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
ASIdentifiers_free(ret->rfc3779_asid);
-
- if (ret->name != NULL)
- OPENSSL_free(ret->name);
+ OPENSSL_free(ret->name);
break;
}
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index a4fded5ec2..39499de591 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -572,8 +572,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
}
ret = 1;
err:
- if (str != NULL)
- OPENSSL_free(str);
+ OPENSSL_free(str);
if ((ret == 0) && (s != INVALID_SOCKET)) {
closesocket(s);
s = INVALID_SOCKET;
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c
index d82385a06c..53a120465a 100644
--- a/crypto/bio/bf_buff.c
+++ b/crypto/bio/bf_buff.c
@@ -127,10 +127,8 @@ static int buffer_free(BIO *a)
if (a == NULL)
return (0);
b = (BIO_F_BUFFER_CTX *)a->ptr;
- if (b->ibuf != NULL)
- OPENSSL_free(b->ibuf);
- if (b->obuf != NULL)
- OPENSSL_free(b->obuf);
+ OPENSSL_free(b->ibuf);
+ OPENSSL_free(b->obuf);
OPENSSL_free(a->ptr);
a->ptr = NULL;
a->init = 0;
@@ -339,8 +337,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
p1 = OPENSSL_malloc((int)num);
if (p1 == NULL)
goto malloc_error;
- if (ctx->ibuf != NULL)
- OPENSSL_free(ctx->ibuf);
+ OPENSSL_free(ctx->ibuf);
ctx->ibuf = p1;
}
ctx->ibuf_off = 0;
diff --git a/crypto/bio/bf_lbuf.c b/crypto/bio/bf_lbuf.c
index ef12820b50..d7906b419c 100644
--- a/crypto/bio/bf_lbuf.c
+++ b/crypto/bio/bf_lbuf.c
@@ -128,8 +128,7 @@ static int linebuffer_free(BIO *a)
if (a == NULL)
return (0);
b = (BIO_LINEBUFFER_CTX *)a->ptr;
- if (b->obuf != NULL)
- OPENSSL_free(b->obuf);
+ OPENSSL_free(b->obuf);
OPENSSL_free(a->ptr);
a->ptr = NULL;
a->init = 0;
diff --git a/crypto/bio/bf_nbio.c b/crypto/bio/bf_nbio.c
index df547a1027..9b9c0c08b2 100644
--- a/crypto/bio/bf_nbio.c
+++ b/crypto/bio/bf_nbio.c
@@ -116,8 +116,7 @@ static int nbiof_free(BIO *a)
{
if (a == NULL)
return (0);
- if (a->ptr != NULL)
- OPENSSL_free(a->ptr);
+ OPENSSL_free(a->ptr);
a->ptr = NULL;
a->init = 0;
a->flags = 0;
diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c
index d6f66789d8..6793fe17ac 100644
--- a/crypto/bio/bss_acpt.c
+++ b/crypto/bio/bss_acpt.c
@@ -151,10 +151,8 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a)
if (a == NULL)
return;
- if (a->param_addr != NULL)
- OPENSSL_free(a->param_addr);
- if (a->addr != NULL)
- OPENSSL_free(a->addr);
+ OPENSSL_free(a->param_addr);
+ OPENSSL_free(a->addr);
BIO_free(a->bio_chain);
OPENSSL_free(a);
}
@@ -353,8 +351,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
if (ptr != NULL) {
if (num == 0) {
b->init = 1;
- if (data->param_addr != NULL)
- OPENSSL_free(data->param_addr);
+ OPENSSL_free(data->param_addr);
data->param_addr = BUF_strdup(ptr);
} else if (num == 1) {
data->accept_nbio = (ptr != NULL);
diff --git a/crypto/bio/bss_bio.c b/crypto/bio/bss_bio.c
index c6bb3d6885..c9b8e7f1c6 100644
--- a/crypto/bio/bss_bio.c
+++ b/crypto/bio/bss_bio.c
@@ -170,10 +170,7 @@ static int bio_free(BIO *bio)
if (b->peer)
bio_destroy_pair(bio);
- if (b->buf != NULL) {
- OPENSSL_free(b->buf);
- }
-
+ OPENSSL_free(b->buf);
OPENSSL_free(b);
return 1;
@@ -507,10 +504,8 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
size_t new_size = num;
if (b->size != new_size) {
- if (b->buf) {
- OPENSSL_free(b->buf);
- b->buf = NULL;
- }
+ OPENSSL_free(b->buf);
+ b->buf = NULL;
b->size = new_size;
}
ret = 1;
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c
index e44bb32dca..0b820820b8 100644
--- a/crypto/bio/bss_conn.c
+++ b/crypto/bio/bss_conn.c
@@ -148,8 +148,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
*q = '\0';
break;
}
- if (c->param_port != NULL)
- OPENSSL_free(c->param_port);
+ OPENSSL_free(c->param_port);
c->param_port = BUF_strdup(p);
}
}
@@ -308,10 +307,8 @@ void BIO_CONNECT_free(BIO_CONNECT *a)
if (a == NULL)
return;
- if (a->param_hostname != NULL)
- OPENSSL_free(a->param_hostname);
- if (a->param_port != NULL)
- OPENSSL_free(a->param_port);
+ OPENSSL_free(a->param_hostname);
+ OPENSSL_free(a->param_port);
OPENSSL_free(a);
}
@@ -455,12 +452,10 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
if (ptr != NULL) {
b->init = 1;
if (num == 0) {
- if (data->param_hostname != NULL)
- OPENSSL_free(data->param_hostname);
+ OPENSSL_free(data->param_hostname);
data->param_hostname = BUF_strdup(ptr);
} else if (num == 1) {
- if (data->param_port != NULL)
- OPENSSL_free(data->param_port);
+ OPENSSL_free(data->param_port);
data->param_port = BUF_strdup(ptr);
} else if (num == 2) {
char buf[16];
@@ -468,16 +463,14 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
BIO_snprintf(buf, sizeof buf, "%d.%d.%d.%d",
p[0], p[1], p[2], p[3]);
- if (data->param_hostname != NULL)
- OPENSSL_free(data->param_hostname);
+ OPENSSL_free(data->param_hostname);
data->param_hostname = BUF_strdup(buf);
memcpy(&(data->ip[0]), ptr, 4);
} else if (num == 3) {
char buf[DECIMAL_SIZE(int) + 1];
BIO_snprintf(buf, sizeof buf, "%d", *(int *)ptr);
- if (data->param_port != NULL)
- OPENSSL_free(data->param_port);
+ OPENSSL_free(data->param_port);
data->param_port = BUF_strdup(buf);
data->port = *(int *)ptr;
}
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index 4fa6279d05..406d46bb6c 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -245,8 +245,7 @@ static int dgram_free(BIO *a)
return 0;
data = (bio_dgram_data *)a->ptr;
- if (data != NULL)
- OPENSSL_free(data);
+ OPENSSL_free(data);
return (1);
}
@@ -1110,8 +1109,7 @@ static int dgram_sctp_free(BIO *a)
data = (bio_dgram_sctp_data *) a->ptr;
if (data != NULL) {
- if (data->saved_message.data != NULL)
- OPENSSL_free(data->saved_message.data);
+ OPENSSL_free(data->saved_message.data);
OPENSSL_free(data);
}
@@ -1413,8 +1411,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
BIOerr(BIO_F_DGRAM_SCTP_WRITE, ERR_R_MALLOC_FAILURE);
return -1;
}
- if (data->saved_message.data)
- OPENSSL_free(data->saved_message.data);
+ OPENSSL_free(data->saved_message.data);
data->saved_message.data = tmp;
memcpy(data->saved_message.data, in, inl);
data->saved_message.length = inl;
diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c
index 28c36931a9..17aa2ba5bf 100644
--- a/crypto/bn/bn_exp.c
+++ b/crypto/bn/bn_exp.c
@@ -1131,8 +1131,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
BN_MONT_CTX_free(mont);
if (powerbuf != NULL) {
OPENSSL_cleanse(powerbuf, powerbufLen);
- if (powerbufFree)
- OPENSSL_free(powerbufFree);
+ OPENSSL_free(powerbufFree);
}
BN_CTX_end(ctx);
return (ret);
diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c
index fc7ad24296..7c0d4afc71 100644
--- a/crypto/bn/bn_gf2m.c
+++ b/crypto/bn/bn_gf2m.c
@@ -561,8 +561,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
bn_check_top(r);
err:
- if (arr)
- OPENSSL_free(arr);
+ OPENSSL_free(arr);
return ret;
}
@@ -620,8 +619,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);
bn_check_top(r);
err:
- if (arr)
- OPENSSL_free(arr);
+ OPENSSL_free(arr);
return ret;
}
@@ -1037,8 +1035,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx);
bn_check_top(r);
err:
- if (arr)
- OPENSSL_free(arr);
+ OPENSSL_free(arr);
return ret;
}
@@ -1097,8 +1094,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx);
bn_check_top(r);
err:
- if (arr)
- OPENSSL_free(arr);
+ OPENSSL_free(arr);
return ret;
}
@@ -1228,8 +1224,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx);
bn_check_top(r);
err:
- if (arr)
- OPENSSL_free(arr);
+ OPENSSL_free(arr);
return ret;
}
diff --git a/crypto/bn/bn_intern.c b/crypto/bn/bn_intern.c
index 32ad50523d..139d11b78e 100644
--- a/crypto/bn/bn_intern.c
+++ b/crypto/bn/bn_intern.c
@@ -67,7 +67,6 @@
signed char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
{
int window_val;
- int ok = 0;
signed char *r = NULL;
int sign = 1;
int bit, next_bit, mask;
@@ -176,17 +175,12 @@ signed char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);
goto err;
}
- len = j;
- ok = 1;
+ *ret_len = j;
+ return r;
err:
- if (!ok) {
- OPENSSL_free(r);
- r = NULL;
- }
- if (ok)
- *ret_len = len;
- return r;
+ OPENSSL_free(r);
+ return NULL;
}
int bn_get_top(const BIGNUM *a)
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 2c5e2b26f8..3e9ea8ef4c 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -246,7 +246,7 @@ void BN_free(BIGNUM *a)
if (a == NULL)
return;
bn_check_top(a);
- if ((a->d != NULL) && !(BN_get_flags(a, BN_FLG_STATIC_DATA)))
+ if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
OPENSSL_free(a->d);
if (a->flags & BN_FLG_MALLOCED)
OPENSSL_free(a);
@@ -378,8 +378,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
BN_ULONG *a = bn_expand_internal(b, words);
if (!a)
return NULL;
- if (b->d)
- OPENSSL_free(b->d);
+ OPENSSL_free(b->d);
b->d = a;
b->dmax = words;
}
diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c
index 8b59e78916..1ef5a879c2 100644
--- a/crypto/bn/bn_print.c
+++ b/crypto/bn/bn_print.c
@@ -156,15 +156,12 @@ char *BN_bn2dec(const BIGNUM *a)
}
ok = 1;
err:
- if (bn_data != NULL)
- OPENSSL_free(bn_data);
+ OPENSSL_free(bn_data);
BN_free(t);
- if (!ok && buf) {
- OPENSSL_free(buf);
- buf = NULL;
- }
-
- return (buf);
+ if (ok)
+ return buf;
+ OPENSSL_free(buf);
+ return NULL;
}
int BN_hex2bn(BIGNUM **bn, const char *a)
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c
index 4681154e38..ed3c3c5911 100644
--- a/crypto/bn/bn_rand.c
+++ b/crypto/bn/bn_rand.c
@@ -351,7 +351,6 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
ret = 1;
err:
- if (k_bytes)
- OPENSSL_free(k_bytes);
+ OPENSSL_free(k_bytes);
return ret;
}
diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c
index d146f845e9..e8274beabf 100644
--- a/crypto/cms/cms_env.c
+++ b/crypto/cms/cms_env.c
@@ -404,8 +404,7 @@ static int cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms,
EVP_PKEY_CTX_free(pctx);
ktri->pctx = NULL;
}
- if (ek)
- OPENSSL_free(ek);
+ OPENSSL_free(ek);
return ret;
}
@@ -472,7 +471,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
err:
EVP_PKEY_CTX_free(ktri->pctx);
ktri->pctx = NULL;
- if (!ret && ek)
+ if (!ret)
OPENSSL_free(ek);
return ret;
@@ -712,7 +711,7 @@ static int cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms,
err:
- if (!r && wkey)
+ if (!r)
OPENSSL_free(wkey);
OPENSSL_cleanse(&actx, sizeof(actx));
@@ -785,7 +784,7 @@ static int cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms,
err:
- if (!r && ukey)
+ if (!r)
OPENSSL_free(ukey);
OPENSSL_cleanse(&actx, sizeof(actx));
diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c
index 6d5fa90a06..21f41f6a4b 100644
--- a/crypto/cms/cms_ess.c
+++ b/crypto/cms/cms_ess.c
@@ -154,8 +154,7 @@ int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr)
if (!r)
CMSerr(CMS_F_CMS_ADD1_RECEIPTREQUEST, ERR_R_MALLOC_FAILURE);
- if (rrder)
- OPENSSL_free(rrder);
+ OPENSSL_free(rrder);
return r;
diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c
index 17b62ddd8c..ea7fb5b8f2 100644
--- a/crypto/cms/cms_kari.c
+++ b/crypto/cms/cms_kari.c
@@ -268,7 +268,7 @@ static int cms_kek_cipher(unsigned char **pout, size_t *poutlen,
err:
OPENSSL_cleanse(kek, keklen);
- if (!rv && out)
+ if (!rv)
OPENSSL_free(out);
EVP_CIPHER_CTX_cleanup(&kari->ctx);
EVP_PKEY_CTX_free(kari->pctx);
@@ -300,8 +300,7 @@ int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,
cek = NULL;
rv = 1;
err:
- if (cek)
- OPENSSL_free(cek);
+ OPENSSL_free(cek);
return rv;
}
diff --git a/crypto/cms/cms_pwri.c b/crypto/cms/cms_pwri.c
index 64165022f3..1d505e9d1c 100644
--- a/crypto/cms/cms_pwri.c
+++ b/crypto/cms/cms_pwri.c
@@ -420,7 +420,7 @@ int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
EVP_CIPHER_CTX_cleanup(&kekctx);
- if (!r && key)
+ if (!r)
OPENSSL_free(key);
X509_ALGOR_free(kekalg);
diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c
index 31398acfe3..7fb4385f60 100644
--- a/crypto/cms/cms_sd.c
+++ b/crypto/cms/cms_sd.c
@@ -728,8 +728,7 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si)
return 1;
err:
- if (abuf)
- OPENSSL_free(abuf);
+ OPENSSL_free(abuf);
EVP_MD_CTX_cleanup(mctx);
return 0;
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c
index aa03f8fda1..4508e7f634 100644
--- a/crypto/comp/c_zlib.c
+++ b/crypto/comp/c_zlib.c
@@ -151,8 +151,7 @@ static int zlib_stateful_init(COMP_CTX *ctx)
CRYPTO_set_ex_data(&ctx->ex_data, zlib_stateful_ex_idx, state);
return 1;
err:
- if (state)
- OPENSSL_free(state);
+ OPENSSL_free(state);
return 0;
}
@@ -606,18 +605,14 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
}
if (ibs != -1) {
- if (ctx->ibuf) {
- OPENSSL_free(ctx->ibuf);
- ctx->ibuf = NULL;
- }
+ OPENSSL_free(ctx->ibuf);
+ ctx->ibuf = NULL;
ctx->ibufsize = ibs;
}
if (obs != -1) {
- if (ctx->obuf) {
- OPENSSL_free(ctx->obuf);
- ctx->obuf = NULL;
- }
+ OPENSSL_free(ctx->obuf);
+ ctx->obuf = NULL;
ctx->obufsize = obs;
}
ret = 1;
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index cba2de199b..b41564b680 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -273,8 +273,7 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
if (!ok) {
if (sk != NULL)
sk_CONF_VALUE_free(sk);
- if (v != NULL)
- OPENSSL_free(v);
+ OPENSSL_free(v);
v = NULL;
}
return (v);
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index ef3fef4400..bd2e8c096e 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -393,14 +393,12 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
}
if (buff != NULL)
BUF_MEM_free(buff);
- if (section != NULL)
- OPENSSL_free(section);
+ OPENSSL_free(section);
return (1);
err:
if (buff != NULL)
BUF_MEM_free(buff);
- if (section != NULL)
- OPENSSL_free(section);
+ OPENSSL_free(section);
if (line != NULL)
*line = eline;
BIO_snprintf(btmp, sizeof btmp, "%ld", eline);
@@ -410,12 +408,9 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
conf->data = NULL;
}
if (v != NULL) {
- if (v->name != NULL)
- OPENSSL_free(v->name);
- if (v->value != NULL)
- OPENSSL_free(v->value);
- if (v != NULL)
- OPENSSL_free(v);
+ OPENSSL_free(v->name);
+ OPENSSL_free(v->value);
+ OPENSSL_free(v);
}
return (0);
}
@@ -595,8 +590,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
buf->data[to++] = *(from++);
}
buf->data[to] = '\0';
- if (*pto != NULL)
- OPENSSL_free(*pto);
+ OPENSSL_free(*pto);
*pto = buf->data;
OPENSSL_free(buf);
return (1);
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
index 9acfca4f71..ce2b177873 100644
--- a/crypto/conf/conf_mod.c
+++ b/crypto/conf/conf_mod.c
@@ -383,10 +383,8 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
memerr:
if (imod) {
- if (imod->name)
- OPENSSL_free(imod->name);
- if (imod->value)
- OPENSSL_free(imod->value);
+ OPENSSL_free(imod->name);
+ OPENSSL_free(imod->value);
OPENSSL_free(imod);
}
diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c
index 6a4223c167..c9374b77f9 100644
--- a/crypto/dh/dh_ameth.c
+++ b/crypto/dh/dh_ameth.c
@@ -187,8 +187,7 @@ static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
return 1;
err:
- if (penc)
- OPENSSL_free(penc);
+ OPENSSL_free(penc);
ASN1_STRING_free(str);
return 0;
@@ -292,8 +291,7 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
return 1;
err:
- if (dp != NULL)
- OPENSSL_free(dp);
+ OPENSSL_free(dp);
ASN1_STRING_free(params);
ASN1_STRING_clear_free(prkey);
return 0;
@@ -422,8 +420,7 @@ static int do_dh_print(BIO *bp, const DH *x, int indent,
err:
DHerr(DH_F_DO_DH_PRINT, reason);
}
- if (m != NULL)
- OPENSSL_free(m);
+ OPENSSL_free(m);
return (ret);
}
@@ -481,11 +478,9 @@ static int int_dh_param_copy(DH *to, const DH *from, int is_x942)
return 0;
if (!int_dh_bn_cpy(&to->j, from->j))
return 0;
- if (to->seed) {
- OPENSSL_free(to->seed);
- to->seed = NULL;
- to->seedlen = 0;
- }
+ OPENSSL_free(to->seed);
+ to->seed = NULL;
+ to->seedlen = 0;
if (from->seed) {
to->seed = BUF_memdup(from->seed, from->seedlen);
if (!to->seed)
diff --git a/crypto/dh/dh_kdf.c b/crypto/dh/dh_kdf.c
index a882cb286e..b812d821e4 100644
--- a/crypto/dh/dh_kdf.c
+++ b/crypto/dh/dh_kdf.c
@@ -180,8 +180,7 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen,
}
rv = 1;
err:
- if (der)
- OPENSSL_free(der);
+ OPENSSL_free(der);
EVP_MD_CTX_cleanup(&mctx);
return rv;
}
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c
index 74bad4dfcf..10e98c63ee 100644
--- a/crypto/dh/dh_lib.c
+++ b/crypto/dh/dh_lib.c
@@ -198,8 +198,7 @@ void DH_free(DH *r)
BN_clear_free(r->g);
BN_clear_free(r->q);
BN_clear_free(r->j);
- if (r->seed)
- OPENSSL_free(r->seed);
+ OPENSSL_free(r->seed);
BN_clear_free(r->counter);
BN_clear_free(r->pub_key);
BN_clear_free(r->priv_key);
diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c
index 069b855aa0..be44c0b201 100644
--- a/crypto/dh/dh_pmeth.c
+++ b/crypto/dh/dh_pmeth.c
@@ -153,8 +153,7 @@ static void pkey_dh_cleanup(EVP_PKEY_CTX *ctx)
{
DH_PKEY_CTX *dctx = ctx->data;
if (dctx) {
- if (dctx->kdf_ukm)
- OPENSSL_free(dctx->kdf_ukm);
+ OPENSSL_free(dctx->kdf_ukm);
ASN1_OBJECT_free(dctx->kdf_oid);
OPENSSL_free(dctx);
}
@@ -230,8 +229,7 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
return 1;
case EVP_PKEY_CTRL_DH_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/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c
index e26ca848dc..e5009ec585 100644
--- a/crypto/dsa/dsa_ameth.c
+++ b/crypto/dsa/dsa_ameth.c
@@ -169,8 +169,7 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
return 1;
err:
- if (penc)
- OPENSSL_free(penc);
+ OPENSSL_free(penc);
ASN1_STRING_free(str);
return 0;
@@ -329,8 +328,7 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
return 1;
err:
- if (dp != NULL)
- OPENSSL_free(dp);
+ OPENSSL_free(dp);
ASN1_STRING_free(params);
ASN1_STRING_clear_free(prkey);
return 0;
@@ -471,8 +469,7 @@ static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype)
goto err;
ret = 1;
err:
- if (m != NULL)
- OPENSSL_free(m);
+ OPENSSL_free(m);
return (ret);
}
@@ -562,8 +559,7 @@ static int dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg,
goto err;
rv = 1;
err:
- if (m)
- OPENSSL_free(m);
+ OPENSSL_free(m);
DSA_SIG_free(dsa_sig);
return rv;
}
diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c
index 1827de8d0b..59946f6579 100644
--- a/crypto/dsa/dsa_gen.c
+++ b/crypto/dsa/dsa_gen.c
@@ -644,8 +644,7 @@ int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
if (h_ret != NULL)
*h_ret = h;
}
- if (seed)
- OPENSSL_free(seed);
+ OPENSSL_free(seed);
if (seed_out != seed_tmp)
OPENSSL_free(seed_tmp);
if (ctx)
diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c
index c119209ab2..7aa1054437 100644
--- a/crypto/dsa/dsa_pmeth.c
+++ b/crypto/dsa/dsa_pmeth.c
@@ -113,8 +113,7 @@ static int pkey_dsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
static void pkey_dsa_cleanup(EVP_PKEY_CTX *ctx)
{
DSA_PKEY_CTX *dctx = ctx->data;
- if (dctx)
- OPENSSL_free(dctx);
+ OPENSSL_free(dctx);
}
static int pkey_dsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig,
diff --git a/crypto/dso/dso_dl.c b/crypto/dso/dso_dl.c
index 989d4d9587..5d5ede03a5 100644
--- a/crypto/dso/dso_dl.c
+++ b/crypto/dso/dso_dl.c
@@ -143,8 +143,7 @@ static int dl_load(DSO *dso)
return (1);
err:
/* Cleanup! */
- if (filename != NULL)
- OPENSSL_free(filename);
+ OPENSSL_free(filename);
if (ptr != NULL)
shl_unload(ptr);
return (0);
diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c
index 8ebb2b59c9..92d951fce3 100644
--- a/crypto/dso/dso_dlfcn.c
+++ b/crypto/dso/dso_dlfcn.c
@@ -182,8 +182,7 @@ static int dlfcn_load(DSO *dso)
return (1);
err:
/* Cleanup! */
- if (filename != NULL)
- OPENSSL_free(filename);
+ OPENSSL_free(filename);
if (ptr != NULL)
dlclose(ptr);
return (0);
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c
index c1d6d2544f..a33a8a85bb 100644
--- a/crypto/dso/dso_lib.c
+++ b/crypto/dso/dso_lib.c
@@ -162,11 +162,8 @@ int DSO_free(DSO *dso)
}
sk_void_free(dso->meth_data);
- if (dso->filename != NULL)
- OPENSSL_free(dso->filename);
- if (dso->loaded_filename != NULL)
- OPENSSL_free(dso->loaded_filename);
-
+ OPENSSL_free(dso->filename);
+ OPENSSL_free(dso->loaded_filename);
OPENSSL_free(dso);
return (1);
}
@@ -360,8 +357,7 @@ int DSO_set_filename(DSO *dso, const char *filename)
return (0);
}
BUF_strlcpy(copied, filename, strlen(filename) + 1);
- if (dso->filename)
- OPENSSL_free(dso->filename);
+ OPENSSL_free(dso->filename);
dso->filename = copied;
return (1);
}
diff --git a/crypto/dso/dso_vms.c b/crypto/dso/dso_vms.c
index 79bbd97122..821e238bd4 100644
--- a/crypto/dso/dso_vms.c
+++ b/crypto/dso/dso_vms.c
@@ -267,10 +267,8 @@ static int vms_load(DSO *dso)
return (1);
err:
/* Cleanup! */
- if (p != NULL)
- OPENSSL_free(p);
- if (filename != NULL)
- OPENSSL_free(filename);
+ OPENSSL_free(p);
+ OPENSSL_free(filename);
return (0);
}
diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c
index 2499fc152b..144d8e63c3 100644
--- a/crypto/dso/dso_win32.c
+++ b/crypto/dso/dso_win32.c
@@ -183,10 +183,8 @@ static int win32_load(DSO *dso)
return (1);
err:
/* Cleanup ! */
- if (filename != NULL)
- OPENSSL_free(filename);
- if (p != NULL)
- OPENSSL_free(p);
+ OPENSSL_free(filename);
+ OPENSSL_free(p);
if (h != NULL)
FreeLibrary(h);
return (0);
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);
}
diff --git a/crypto/ecdh/ech_ossl.c b/crypto/ecdh/ech_ossl.c
index 6297706a2a..ad3482fab7 100644
--- a/crypto/ecdh/ech_ossl.c
+++ b/crypto/ecdh/ech_ossl.c
@@ -206,7 +206,6 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
if (ctx)
BN_CTX_end(ctx);
BN_CTX_free(ctx);
- if (buf)
- OPENSSL_free(buf);
+ OPENSSL_free(buf);
return (ret);
}
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index a3be0d79ed..d801ae8f1c 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -889,11 +889,9 @@ static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
return (0);
}
- if (state->mac_data) {
- OPENSSL_free(state->mac_data);
- state->mac_data = NULL;
- state->mac_len = 0;
- }
+ OPENSSL_free(state->mac_data);
+ state->mac_data = NULL;
+ state->mac_len = 0;
if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
printf("cryptodev_digest_cleanup: failed to close session\n");
diff --git a/crypto/engine/eng_dyn.c b/crypto/engine/eng_dyn.c
index 31ec324422..7dd3659e76 100644
--- a/crypto/engine/eng_dyn.c
+++ b/crypto/engine/eng_dyn.c
@@ -136,11 +136,11 @@ struct st_dynamic_data_ctx {
*/
dynamic_bind_engine bind_engine;
/* The default name/path for loading the shared library */
- const char *DYNAMIC_LIBNAME;
+ char *DYNAMIC_LIBNAME;
/* Whether to continue loading on a version check failure */
int no_vcheck;
/* If non-NULL, stipulates the 'id' of the ENGINE to be loaded */
- const char *engine_id;
+ char *engine_id;
/*
* If non-zero, a successfully loaded ENGINE should be added to the
* internal ENGINE list. If 2, the add must succeed or the entire load
@@ -188,10 +188,8 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr;
if (ctx->dynamic_dso)
DSO_free(ctx->dynamic_dso);
- if (ctx->DYNAMIC_LIBNAME)
- OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
- if (ctx->engine_id)
- OPENSSL_free((void *)ctx->engine_id);
+ OPENSSL_free(ctx->DYNAMIC_LIBNAME);
+ OPENSSL_free(ctx->engine_id);
if (ctx->dirs)
sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str);
OPENSSL_free(ctx);
@@ -243,8 +241,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
* If we lost the race to set the context, c is non-NULL and *ctx is the
* context of the thread that won.
*/
- if (c)
- OPENSSL_free(c);
+ OPENSSL_free(c);
return 1;
}
@@ -363,8 +360,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
/* a NULL 'p' or a string of zero-length is the same thing */
if (p && (strlen((const char *)p) < 1))
p = NULL;
- if (ctx->DYNAMIC_LIBNAME)
- OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
+ OPENSSL_free(ctx->DYNAMIC_LIBNAME);
if (p)
ctx->DYNAMIC_LIBNAME = BUF_strdup(p);
else
@@ -377,8 +373,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
/* a NULL 'p' or a string of zero-length is the same thing */
if (p && (strlen((const char *)p) < 1))
p = NULL;
- if (ctx->engine_id)
- OPENSSL_free((void *)ctx->engine_id);
+ OPENSSL_free(ctx->engine_id);
if (p)
ctx->engine_id = BUF_strdup(p);
else
diff --git a/crypto/err/err.c b/crypto/err/err.c
index ec7da22e5b..9d58f38144 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -478,8 +478,7 @@ static void build_SYS_str_reasons(void)
#define err_clear_data(p,i) \
do { \
- if (((p)->err_data[i] != NULL) && \
- (p)->err_data_flags[i] & ERR_TXT_MALLOCED) \
+ if ((p)->err_data_flags[i] & ERR_TXT_MALLOCED) \
{ \
OPENSSL_free((p)->err_data[i]); \
(p)->err_data[i]=NULL; \
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 3468b6b3fb..c2387b9ace 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -523,8 +523,7 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
{
EVP_CIPHER_CTX_cleanup(ctx);
- if (ctx)
- OPENSSL_free(ctx);
+ OPENSSL_free(ctx);
}
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
@@ -538,8 +537,7 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
if (c->cipher_data)
OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
}
- if (c->cipher_data)
- OPENSSL_free(c->cipher_data);
+ OPENSSL_free(c->cipher_data);
#ifndef OPENSSL_NO_ENGINE
if (c->engine)
/*
diff --git a/crypto/ex_data.c b/crypto/ex_data.c
index 6a567c9924..66070f6806 100644
--- a/crypto/ex_data.c
+++ b/crypto/ex_data.c
@@ -444,8 +444,7 @@ static int int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
storage[i]->argl, storage[i]->argp);
}
}
- if (storage)
- OPENSSL_free(storage);
+ OPENSSL_free(storage);
return 1;
}
@@ -487,8 +486,7 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
storage[i]->argl, storage[i]->argp);
CRYPTO_set_ex_data(to, i, ptr);
}
- if (storage)
- OPENSSL_free(storage);
+ OPENSSL_free(storage);
return 1;
}
@@ -525,8 +523,7 @@ static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
storage[i]->argl, storage[i]->argp);
}
}
- if (storage)
- OPENSSL_free(storage);
+ OPENSSL_free(storage);
if (ad->sk) {
sk_void_free(ad->sk);
ad->sk = NULL;
diff --git a/crypto/mem.c b/crypto/mem.c
index 6176b38d75..14f67a443f 100644
--- a/crypto/mem.c
+++ b/crypto/mem.c
@@ -453,8 +453,7 @@ void CRYPTO_clear_free(void *str, size_t num)
void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
{
- if (a != NULL)
- OPENSSL_free(a);
+ OPENSSL_free(a);
a = OPENSSL_malloc(num);
return (a);
}
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index 46c4f878d1..bca3dedd79 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -276,8 +276,7 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
ao[i]->obj = o;
aop = lh_ADDED_OBJ_insert(added, ao[i]);
/* memory leak, buit should not normally matter */
- if (aop != NULL)
- OPENSSL_free(aop);
+ OPENSSL_free(aop);
}
}
o->flags &=
@@ -289,10 +288,8 @@ int OBJ_add_object(const ASN1_OBJECT *obj)
OBJerr(OBJ_F_OBJ_ADD_OBJECT, ERR_R_MALLOC_FAILURE);
err:
for (i = ADDED_DATA; i <= ADDED_NID; i++)
- if (ao[i] != NULL)
- OPENSSL_free(ao[i]);
- if (o != NULL)
- OPENSSL_free(o);
+ OPENSSL_free(ao[i]);
+ OPENSSL_free(o);
return (NID_undef);
}
diff --git a/crypto/objects/obj_lib.c b/crypto/objects/obj_lib.c
index 0bcb5df506..58e9a92fe4 100644
--- a/crypto/objects/obj_lib.c
+++ b/crypto/objects/obj_lib.c
@@ -114,14 +114,10 @@ ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
return (r);
err:
OBJerr(OBJ_F_OBJ_DUP, ERR_R_MALLOC_FAILURE);
- if (ln != NULL)
- OPENSSL_free(ln);
- if (sn != NULL)
- OPENSSL_free(sn);
- if (data != NULL)
- OPENSSL_free(data);
- if (r != NULL)
- OPENSSL_free(r);
+ OPENSSL_free(ln);
+ OPENSSL_free(sn);
+ OPENSSL_free(data);
+ OPENSSL_free(r);
return (NULL);
}
diff --git a/crypto/ocsp/ocsp_ext.c b/crypto/ocsp/ocsp_ext.c
index 520b55afc7..91eac9b1c0 100644
--- a/crypto/ocsp/ocsp_ext.c
+++ b/crypto/ocsp/ocsp_ext.c
@@ -326,8 +326,7 @@ static int ocsp_add1_nonce(STACK_OF(X509_EXTENSION) **exts,
goto err;
ret = 1;
err:
- if (os.data)
- OPENSSL_free(os.data);
+ OPENSSL_free(os.data);
return ret;
}
diff --git a/crypto/ocsp/ocsp_ht.c b/crypto/ocsp/ocsp_ht.c
index 266b43b00a..aa10c0345c 100644
--- a/crypto/ocsp/ocsp_ht.c
+++ b/crypto/ocsp/ocsp_ht.c
@@ -139,8 +139,7 @@ void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)
if (!rctx)
return;
BIO_free(rctx->mem);
- if (rctx->iobuf)
- OPENSSL_free(rctx->iobuf);
+ OPENSSL_free(rctx->iobuf);
OPENSSL_free(rctx);
}
diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c
index 34df9ac04e..ac64b65235 100644
--- a/crypto/ocsp/ocsp_lib.c
+++ b/crypto/ocsp/ocsp_lib.c
@@ -273,14 +273,10 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
OCSPerr(OCSP_F_OCSP_PARSE_URL, OCSP_R_ERROR_PARSING_URL);
err:
- if (buf)
- OPENSSL_free(buf);
- if (*ppath)
- OPENSSL_free(*ppath);
- if (*pport)
- OPENSSL_free(*pport);
- if (*phost)
- OPENSSL_free(*phost);
+ OPENSSL_free(buf);
+ OPENSSL_free(*ppath);
+ OPENSSL_free(*pport);
+ OPENSSL_free(*phost);
return 0;
}
diff --git a/crypto/pem/pem_info.c b/crypto/pem/pem_info.c
index 0e7338bd1d..29670ed35f 100644
--- a/crypto/pem/pem_info.c
+++ b/crypto/pem/pem_info.c
@@ -253,14 +253,11 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
} else {
/* unknown */
}
- if (name != NULL)
- OPENSSL_free(name);
- if (header != NULL)
- OPENSSL_free(header);
- if (data != NULL)
- OPENSSL_free(data);
+ OPENSSL_free(name);
name = NULL;
+ OPENSSL_free(header);
header = NULL;
+ OPENSSL_free(data);
data = NULL;
}
@@ -287,12 +284,9 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
ret = NULL;
}
- if (name != NULL)
- OPENSSL_free(name);
- if (header != NULL)
- OPENSSL_free(header);
- if (data != NULL)
- OPENSSL_free(data);
+ OPENSSL_free(name);
+ OPENSSL_free(header);
+ OPENSSL_free(data);
return (ret);
}
diff --git a/crypto/pem/pem_seal.c b/crypto/pem/pem_seal.c
index 374273d14f..a3812b80d2 100644
--- a/crypto/pem/pem_seal.c
+++ b/crypto/pem/pem_seal.c
@@ -112,8 +112,7 @@ int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
ret = npubk;
err:
- if (s != NULL)
- OPENSSL_free(s);
+ OPENSSL_free(s);
OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH);
return (ret);
}
@@ -181,8 +180,7 @@ int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
err:
EVP_MD_CTX_cleanup(&ctx->md);
EVP_CIPHER_CTX_cleanup(&ctx->cipher);
- if (s != NULL)
- OPENSSL_free(s);
+ OPENSSL_free(s);
return (ret);
}
#else /* !OPENSSL_NO_RSA */
diff --git a/crypto/pem/pem_sign.c b/crypto/pem/pem_sign.c
index 87cc7273de..e16be4a264 100644
--- a/crypto/pem/pem_sign.c
+++ b/crypto/pem/pem_sign.c
@@ -95,7 +95,6 @@ int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
ret = 1;
err:
/* ctx has been zeroed by EVP_SignFinal() */
- if (m != NULL)
- OPENSSL_free(m);
+ OPENSSL_free(m);
return (ret);
}
diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c
index b44912bc50..9e9c948532 100644
--- a/crypto/pem/pvkfmt.c
+++ b/crypto/pem/pvkfmt.c
@@ -285,8 +285,7 @@ static EVP_PKEY *do_b2i_bio(BIO *in, int ispub)
ret = b2i_rsa(&p, length, bitlen, ispub);
err:
- if (buf)
- OPENSSL_free(buf);
+ OPENSSL_free(buf);
return ret;
}
@@ -737,7 +736,7 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in,
ret = b2i_PrivateKey(&p, keylen);
err:
EVP_CIPHER_CTX_cleanup(&cctx);
- if (enctmp && saltlen)
+ if (saltlen)
OPENSSL_free(enctmp);
return ret;
}
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c
index 4bc06b95c2..e5ad95fb1d 100644
--- a/crypto/pkcs7/pk7_doit.c
+++ b/crypto/pkcs7/pk7_doit.c
@@ -181,8 +181,7 @@ static int pkcs7_encode_rinfo(PKCS7_RECIP_INFO *ri,
err:
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(pctx);
- if (ek)
- OPENSSL_free(ek);
+ OPENSSL_free(ek);
return ret;
}
@@ -235,7 +234,7 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
err:
EVP_PKEY_CTX_free(pctx);
- if (!ret && ek)
+ if (!ret)
OPENSSL_free(ek);
return ret;
@@ -890,8 +889,7 @@ int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si)
return 1;
err:
- if (abuf)
- OPENSSL_free(abuf);
+ OPENSSL_free(abuf);
EVP_MD_CTX_cleanup(&mctx);
return 0;
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;
diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c
index d4ac91e8fb..7611631309 100644
--- a/crypto/stack/stack.c
+++ b/crypto/stack/stack.c
@@ -167,8 +167,7 @@ _STACK *sk_new(int (*c) (const void *, const void *))
ret->sorted = 0;
return (ret);
err:
- if (ret)
- OPENSSL_free(ret);
+ OPENSSL_free(ret);
return (NULL);
}
@@ -318,8 +317,7 @@ void sk_free(_STACK *st)
{
if (st == NULL)
return;
- if (st->data != NULL)
- OPENSSL_free(st->data);
+ OPENSSL_free(st->data);
OPENSSL_free(st);
}
diff --git a/crypto/store/str_mem.c b/crypto/store/str_mem.c
index f949b34dfb..8687100761 100644
--- a/crypto/store/str_mem.c
+++ b/crypto/store/str_mem.c
@@ -348,8 +348,7 @@ static int mem_list_end(STORE *s, void *handle)
}
if (context && context->search_attributes)
sk_STORE_ATTR_INFO_free(context->search_attributes);
- if (context)
- OPENSSL_free(context);
+ OPENSSL_free(context);
return 1;
}
diff --git a/crypto/threads/th-lock.c b/crypto/threads/th-lock.c
index 6732dd76ed..e74474a9b3 100644
--- a/crypto/threads/th-lock.c
+++ b/crypto/threads/th-lock.c
@@ -318,10 +318,8 @@ void CRYPTO_thread_setup(void)
lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
if (!lock_cs || !lock_count) {
/* Nothing we can do about this...void function! */
- if (lock_cs)
- OPENSSL_free(lock_cs);
- if (lock_count)
- OPENSSL_free(lock_count);
+ OPENSSL_free(lock_cs);
+ OPENSSL_free(lock_count);
return;
}
for (i = 0; i < CRYPTO_num_locks(); i++) {
diff --git a/crypto/txt_db/txt_db.c b/crypto/txt_db/txt_db.c
index 7f0548fd88..029d0bb2fe 100644
--- a/crypto/txt_db/txt_db.c
+++ b/crypto/txt_db/txt_db.c
@@ -184,12 +184,9 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
if (ret != NULL) {
if (ret->data != NULL)
sk_OPENSSL_PSTRING_free(ret->data);
- if (ret->index != NULL)
- OPENSSL_free(ret->index);
- if (ret->qual != NULL)
- OPENSSL_free(ret->qual);
- if (ret != NULL)
- OPENSSL_free(ret);
+ OPENSSL_free(ret->index);
+ OPENSSL_free(ret->qual);
+ OPENSSL_free(ret);
}
return (NULL);
} else
@@ -350,8 +347,7 @@ void TXT_DB_free(TXT_DB *db)
lh_OPENSSL_STRING_free(db->index[i]);
OPENSSL_free(db->index);
}
- if (db->qual != NULL)
- OPENSSL_free(db->qual);
+ OPENSSL_free(db->qual);
if (db->data != NULL) {
for (i = sk_OPENSSL_PSTRING_num(db->data) - 1; i >= 0; i--) {
/*
@@ -362,12 +358,10 @@ void TXT_DB_free(TXT_DB *db)
max = p[db->num_fields]; /* last address */
if (max == NULL) { /* new row */
for (n = 0; n < db->num_fields; n++)
- if (p[n] != NULL)
- OPENSSL_free(p[n]);
+ OPENSSL_free(p[n]);
} else {
for (n = 0; n < db->num_fields; n++) {
- if (((p[n] < (char *)p) || (p[n] > max))
- && (p[n] != NULL))
+ if (((p[n] < (char *)p) || (p[n] > max)))
OPENSSL_free(p[n]);
}
}
diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c
index d2732f5bf2..26afbd23f7 100644
--- a/crypto/ui/ui_lib.c
+++ b/crypto/ui/ui_lib.c
@@ -335,14 +335,10 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
ok_chars_copy, cancel_chars_copy, 1,
UIT_BOOLEAN, flags, result_buf);
err:
- if (prompt_copy)
- OPENSSL_free(prompt_copy);
- if (action_desc_copy)
- OPENSSL_free(action_desc_copy);
- if (ok_chars_copy)
- OPENSSL_free(ok_chars_copy);
- if (cancel_chars_copy)
- OPENSSL_free(cancel_chars_copy);
+ OPENSSL_free(prompt_copy);
+ OPENSSL_free(action_desc_copy);
+ OPENSSL_free(ok_chars_copy);
+ OPENSSL_free(cancel_chars_copy);
return -1;
}
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index b30fa30d5f..31b3c3c9dc 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -176,8 +176,7 @@ static int by_dir_hash_cmp(const BY_DIR_HASH *const *a,
static void by_dir_entry_free(BY_DIR_ENTRY *ent)
{
- if (ent->dir)
- OPENSSL_free(ent->dir);
+ OPENSSL_free(ent->dir);
if (ent->hashes)
sk_BY_DIR_HASH_pop_free(ent->hashes, by_dir_hash_free);
OPENSSL_free(ent);
diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c
index 57c2606bbb..b0d9c4de91 100644
--- a/crypto/x509/x509_vpm.c
+++ b/crypto/x509/x509_vpm.c
@@ -149,19 +149,13 @@ static void x509_verify_param_zero(X509_VERIFY_PARAM *param)
paramid = param->id;
string_stack_free(paramid->hosts);
paramid->hosts = NULL;
- if (paramid->peername)
- OPENSSL_free(paramid->peername);
- if (paramid->email) {
- OPENSSL_free(paramid->email);
- paramid->email = NULL;
- paramid->emaillen = 0;
- }
- if (paramid->ip) {
- OPENSSL_free(paramid->ip);
- paramid->ip = NULL;
- paramid->iplen = 0;
- }
-
+ OPENSSL_free(paramid->peername);
+ OPENSSL_free(paramid->email);
+ paramid->email = NULL;
+ paramid->emaillen = 0;
+ OPENSSL_free(paramid->ip);
+ paramid->ip = NULL;
+ paramid->iplen = 0;
}
X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void)
@@ -346,8 +340,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
tmp = NULL;
srclen = 0;
}
- if (*pdest)
- OPENSSL_free(*pdest);
+ OPENSSL_free(*pdest);
*pdest = tmp;
if (pdestlen)
*pdestlen = srclen;
@@ -356,8 +349,7 @@ static int int_x509_param_set1(char **pdest, size_t *pdestlen,
int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name)
{
- if (param->name)
- OPENSSL_free(param->name);
+ OPENSSL_free(param->name);
param->name = BUF_strdup(name);
if (param->name)
return 1;
diff --git a/crypto/x509/x509spki.c b/crypto/x509/x509spki.c
index 347ab4cd7b..fb46d4e3af 100644
--- a/crypto/x509/x509spki.c
+++ b/crypto/x509/x509spki.c
@@ -113,10 +113,8 @@ char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki)
b64_str = OPENSSL_malloc(der_len * 2);
if (!der_spki || !b64_str) {
X509err(X509_F_NETSCAPE_SPKI_B64_ENCODE, ERR_R_MALLOC_FAILURE);
- if (der_spki != NULL)
- OPENSSL_free(der_spki);
- if (b64_str != NULL)
- OPENSSL_free(b64_str);
+ OPENSSL_free(der_spki);
+ OPENSSL_free(b64_str);
return NULL;
}
p = der_spki;
diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c
index cdc4c973b3..cab7171474 100644
--- a/crypto/x509/x_name.c
+++ b/crypto/x509/x_name.c
@@ -166,8 +166,7 @@ static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
BUF_MEM_free(a->bytes);
sk_X509_NAME_ENTRY_pop_free(a->entries, X509_NAME_ENTRY_free);
- if (a->canon_enc)
- OPENSSL_free(a->canon_enc);
+ OPENSSL_free(a->canon_enc);
OPENSSL_free(a);
*pval = NULL;
}
@@ -343,10 +342,8 @@ static int x509_name_canon(X509_NAME *a)
X509_NAME_ENTRY *entry, *tmpentry = NULL;
int i, set = -1, ret = 0;
- if (a->canon_enc) {
- OPENSSL_free(a->canon_enc);
- a->canon_enc = NULL;
- }
+ OPENSSL_free(a->canon_enc);
+ a->canon_enc = NULL;
/* Special case: empty X509_NAME => null encoding */
if (sk_X509_NAME_ENTRY_num(a->entries) == 0) {
a->canon_enclen = 0;
diff --git a/crypto/x509v3/v3_conf.c b/crypto/x509v3/v3_conf.c
index eb9cfea66d..0997d599a9 100644
--- a/crypto/x509v3/v3_conf.c
+++ b/crypto/x509v3/v3_conf.c
@@ -210,8 +210,7 @@ static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method,
merr:
X509V3err(X509V3_F_DO_EXT_I2D, ERR_R_MALLOC_FAILURE);
- if (ext_der != NULL)
- OPENSSL_free(ext_der);
+ OPENSSL_free(ext_der);
ASN1_OCTET_STRING_free(ext_oct);
return NULL;
@@ -305,8 +304,7 @@ static X509_EXTENSION *v3_generic_extension(const char *ext, char *value,
err:
ASN1_OBJECT_free(obj);
ASN1_OCTET_STRING_free(oct);
- if (ext_der)
- OPENSSL_free(ext_der);
+ OPENSSL_free(ext_der);
return extension;
}
diff --git a/crypto/x509v3/v3_prn.c b/crypto/x509v3/v3_prn.c
index 9d093a364d..633dacafc2 100644
--- a/crypto/x509v3/v3_prn.c
+++ b/crypto/x509v3/v3_prn.c
@@ -176,8 +176,7 @@ int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
err:
sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
- if (value)
- OPENSSL_free(value);
+ OPENSSL_free(value);
if (method->it)
ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it));
else
diff --git a/crypto/x509v3/v3_scts.c b/crypto/x509v3/v3_scts.c
index ecfc68dcb7..2bbc05655b 100644
--- a/crypto/x509v3/v3_scts.c
+++ b/crypto/x509v3/v3_scts.c
@@ -163,8 +163,7 @@ static void SCT_free(SCT *sct)
{
if (!sct)
return;
- if (sct->sct)
- OPENSSL_free(sct->sct);
+ OPENSSL_free(sct->sct);
OPENSSL_free(sct);
}
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index 5de60ce848..71422083e7 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -100,12 +100,9 @@ int X509V3_add_value(const char *name, const char *value,
return 1;
err:
X509V3err(X509V3_F_X509V3_ADD_VALUE, ERR_R_MALLOC_FAILURE);
- if (vtmp)
- OPENSSL_free(vtmp);
- if (tname)
- OPENSSL_free(tname);
- if (tvalue)
- OPENSSL_free(tvalue);
+ OPENSSL_free(vtmp);
+ OPENSSL_free(tname);
+ OPENSSL_free(tvalue);
return 0;
}
@@ -121,12 +118,9 @@ void X509V3_conf_free(CONF_VALUE *conf)
{
if (!conf)
return;
- if (conf->name)
- OPENSSL_free(conf->name);
- if (conf->value)
- OPENSSL_free(conf->value);
- if (conf->section)
- OPENSSL_free(conf->section);
+ OPENSSL_free(conf->name);
+ OPENSSL_free(conf->value);
+ OPENSSL_free(conf->section);
OPENSSL_free(conf);
}
@@ -472,8 +466,7 @@ unsigned char *string_to_hex(const char *str, long *len)
return hexbuf;
err:
- if (hexbuf)
- OPENSSL_free(hexbuf);
+ OPENSSL_free(hexbuf);
X509V3err(X509V3_F_STRING_TO_HEX, ERR_R_MALLOC_FAILURE);
return NULL;
@@ -1108,8 +1101,7 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc)
return ret;
err:
- if (iptmp)
- OPENSSL_free(iptmp);
+ OPENSSL_free(iptmp);
ASN1_OCTET_STRING_free(ret);
return NULL;
}