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 | |
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')
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 |