summaryrefslogtreecommitdiffstats
path: root/crypto
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
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')
-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)