diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-30 11:30:03 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-30 11:31:07 -0400 |
commit | 2ace745022f5af0709297e96eb0b0829c87c4291 (patch) | |
tree | 4352672cd8681d1df32edd39443c50a98fe0b065 /crypto/asn1 | |
parent | 5a80d9fbfe445420ffe6b649f29e2e0c412aba5d (diff) |
free NULL cleanup 8
Do not check for NULL before calling a free routine. This addresses:
ASN1_BIT_STRING_free ASN1_GENERALIZEDTIME_free ASN1_INTEGER_free
ASN1_OBJECT_free ASN1_OCTET_STRING_free ASN1_PCTX_free ASN1_SCTX_free
ASN1_STRING_clear_free ASN1_STRING_free ASN1_TYPE_free
ASN1_UTCTIME_free M_ASN1_free_of
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/a_object.c | 2 | ||||
-rw-r--r-- | crypto/asn1/asn1_gen.c | 3 | ||||
-rw-r--r-- | crypto/asn1/tasn_prn.c | 3 | ||||
-rw-r--r-- | crypto/asn1/tasn_scn.c | 3 | ||||
-rw-r--r-- | crypto/asn1/x_algor.c | 6 | ||||
-rw-r--r-- | crypto/asn1/x_x509a.c | 4 |
6 files changed, 10 insertions, 11 deletions
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 166eb65a48..2b5a4940fe 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -339,7 +339,7 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, return (ret); err: ASN1err(ASN1_F_C2I_ASN1_OBJECT, i); - if ((ret != NULL) && ((a == NULL) || (*a != ret))) + if ((a == NULL) || (*a != ret)) ASN1_OBJECT_free(ret); return (NULL); } diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c index cee37495e2..3e066bc3e8 100644 --- a/crypto/asn1/asn1_gen.c +++ b/crypto/asn1/asn1_gen.c @@ -513,8 +513,7 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf, if (der) OPENSSL_free(der); - if (sk) - sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); + sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); if (sect) X509V3_section_free(cnf, sect); diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c index 76d584b2ba..10974eb7f4 100644 --- a/crypto/asn1/tasn_prn.c +++ b/crypto/asn1/tasn_prn.c @@ -100,7 +100,8 @@ ASN1_PCTX *ASN1_PCTX_new(void) void ASN1_PCTX_free(ASN1_PCTX *p) { - OPENSSL_free(p); + if (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 cedea9cb78..830540550e 100644 --- a/crypto/asn1/tasn_scn.c +++ b/crypto/asn1/tasn_scn.c @@ -86,7 +86,8 @@ ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx)) void ASN1_SCTX_free(ASN1_SCTX *p) { - OPENSSL_free(p); + if (p) + OPENSSL_free(p); } const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p) diff --git a/crypto/asn1/x_algor.c b/crypto/asn1/x_algor.c index 30d648159f..ca2749179f 100644 --- a/crypto/asn1/x_algor.c +++ b/crypto/asn1/x_algor.c @@ -92,10 +92,8 @@ int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval) if (ptype == 0) return 1; if (ptype == V_ASN1_UNDEF) { - if (alg->parameter) { - ASN1_TYPE_free(alg->parameter); - alg->parameter = NULL; - } + ASN1_TYPE_free(alg->parameter); + alg->parameter = NULL; } else ASN1_TYPE_set(alg->parameter, ptype, pval); return 1; diff --git a/crypto/asn1/x_x509a.c b/crypto/asn1/x_x509a.c index 8be50b55e2..775e46f516 100644 --- a/crypto/asn1/x_x509a.c +++ b/crypto/asn1/x_x509a.c @@ -178,7 +178,7 @@ int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj) void X509_trust_clear(X509 *x) { - if (x->aux && x->aux->trust) { + if (x->aux) { sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free); x->aux->trust = NULL; } @@ -186,7 +186,7 @@ void X509_trust_clear(X509 *x) void X509_reject_clear(X509 *x) { - if (x->aux && x->aux->reject) { + if (x->aux) { sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free); x->aux->reject = NULL; } |