diff options
Diffstat (limited to 'lib')
44 files changed, 103 insertions, 212 deletions
diff --git a/lib/libcrypto/asn1/a_bitstr.c b/lib/libcrypto/asn1/a_bitstr.c index f3cce8b5366..058a3ccc5fa 100644 --- a/lib/libcrypto/asn1/a_bitstr.c +++ b/lib/libcrypto/asn1/a_bitstr.c @@ -165,8 +165,7 @@ c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, const unsigned char **pp, long len) s = NULL; ret->length = (int)len; - if (ret->data != NULL) - free(ret->data); + free(ret->data); ret->data = s; ret->type = V_ASN1_BIT_STRING; if (a != NULL) diff --git a/lib/libcrypto/asn1/a_bytes.c b/lib/libcrypto/asn1/a_bytes.c index 6cc774e7828..0d26e46681c 100644 --- a/lib/libcrypto/asn1/a_bytes.c +++ b/lib/libcrypto/asn1/a_bytes.c @@ -110,8 +110,7 @@ d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp, } else s = NULL; - if (ret->data != NULL) - free(ret->data); + free(ret->data); ret->length = (int)len; ret->data = s; ret->type = tag; @@ -203,8 +202,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, } else { if (len != 0) { if ((ret->length < len) || (ret->data == NULL)) { - if (ret->data != NULL) - free(ret->data); + free(ret->data); ret->data = NULL; s = malloc(len + 1); if (s == NULL) { @@ -218,8 +216,7 @@ d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp, p += len; } else { s = NULL; - if (ret->data != NULL) - free(ret->data); + free(ret->data); } ret->length = (int)len; @@ -293,8 +290,7 @@ asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c) goto err; a->length = num; - if (a->data != NULL) - free(a->data); + free(a->data); a->data = (unsigned char *)b.data; if (os != NULL) ASN1_STRING_free(os); @@ -304,7 +300,6 @@ err: ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE, c->error); if (os != NULL) ASN1_STRING_free(os); - if (b.data != NULL) - free(b.data); + free(b.data); return (0); } diff --git a/lib/libcrypto/asn1/a_enum.c b/lib/libcrypto/asn1/a_enum.c index aa28c7c8d78..b5142887821 100644 --- a/lib/libcrypto/asn1/a_enum.c +++ b/lib/libcrypto/asn1/a_enum.c @@ -76,8 +76,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) a->type = V_ASN1_ENUMERATED; if (a->length < (int)(sizeof(long) + 1)) { - if (a->data != NULL) - free(a->data); + free(a->data); a->data = calloc(1, sizeof(long) + 1); } if (a->data == NULL) { diff --git a/lib/libcrypto/asn1/a_gentm.c b/lib/libcrypto/asn1/a_gentm.c index 7f8bc2fef72..e9881943a17 100644 --- a/lib/libcrypto/asn1/a_gentm.c +++ b/lib/libcrypto/asn1/a_gentm.c @@ -234,8 +234,7 @@ ASN1_GENERALIZEDTIME_adj_internal(ASN1_GENERALIZEDTIME *s, time_t t, ERR_R_MALLOC_FAILURE); return (NULL); } - if (s->data != NULL) - free(s->data); + free(s->data); s->data = (unsigned char *)p; } diff --git a/lib/libcrypto/asn1/a_int.c b/lib/libcrypto/asn1/a_int.c index 0559cce3843..881f08a7669 100644 --- a/lib/libcrypto/asn1/a_int.c +++ b/lib/libcrypto/asn1/a_int.c @@ -256,8 +256,7 @@ c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) memcpy(s, p, (int)len); } - if (ret->data != NULL) - free(ret->data); + free(ret->data); ret->data = s; ret->length = (int)len; if (a != NULL) @@ -324,8 +323,7 @@ d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length) p += len; } - if (ret->data != NULL) - free(ret->data); + free(ret->data); ret->data = s; ret->length = (int)len; if (a != NULL) @@ -350,8 +348,7 @@ ASN1_INTEGER_set(ASN1_INTEGER *a, long v) a->type = V_ASN1_INTEGER; if (a->length < (int)(sizeof(long) + 1)) { - if (a->data != NULL) - free(a->data); + free(a->data); a->data = calloc(1, sizeof(long) + 1); } if (a->data == NULL) { diff --git a/lib/libcrypto/asn1/a_object.c b/lib/libcrypto/asn1/a_object.c index b3a7e672eeb..34221e0e984 100644 --- a/lib/libcrypto/asn1/a_object.c +++ b/lib/libcrypto/asn1/a_object.c @@ -310,8 +310,7 @@ c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, long len) /* once detached we can change it */ if ((data == NULL) || (ret->length < len)) { ret->length = 0; - if (data != NULL) - free(data); + free(data); data = malloc(len ? (int)len : 1); if (data == NULL) { i = ERR_R_MALLOC_FAILURE; @@ -365,15 +364,12 @@ ASN1_OBJECT_free(ASN1_OBJECT *a) if (a == NULL) return; if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_STRINGS) { - if (a->sn != NULL) - free((void *)a->sn); - if (a->ln != NULL) - free((void *)a->ln); + free((void *)a->sn); + free((void *)a->ln); a->sn = a->ln = NULL; } if (a->flags & ASN1_OBJECT_FLAG_DYNAMIC_DATA) { - if (a->data != NULL) - free((void *)a->data); + free((void *)a->data); a->data = NULL; a->length = 0; } diff --git a/lib/libcrypto/asn1/a_sign.c b/lib/libcrypto/asn1/a_sign.c index 40c68096696..2705a0402e3 100644 --- a/lib/libcrypto/asn1/a_sign.c +++ b/lib/libcrypto/asn1/a_sign.c @@ -218,8 +218,7 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); goto err; } - if (signature->data != NULL) - free(signature->data); + free(signature->data); signature->data = buf_out; buf_out = NULL; signature->length = outl; diff --git a/lib/libcrypto/asn1/a_utctm.c b/lib/libcrypto/asn1/a_utctm.c index 35f2b7fd668..b8e5b7afc14 100644 --- a/lib/libcrypto/asn1/a_utctm.c +++ b/lib/libcrypto/asn1/a_utctm.c @@ -177,8 +177,7 @@ ASN1_UTCTIME_adj_internal(ASN1_UTCTIME *s, time_t t, int offset_day, ASN1err(ASN1_F_ASN1_UTCTIME_ADJ, ERR_R_MALLOC_FAILURE); return (NULL); } - if (s->data != NULL) - free(s->data); + free(s->data); s->data = (unsigned char *)p; } diff --git a/lib/libcrypto/asn1/asn1_gen.c b/lib/libcrypto/asn1/asn1_gen.c index 7abbac6059c..8ab8944d649 100644 --- a/lib/libcrypto/asn1/asn1_gen.c +++ b/lib/libcrypto/asn1/asn1_gen.c @@ -474,8 +474,7 @@ asn1_multi(int utype, const char *section, X509V3_CTX *cnf) der = NULL; bad: - if (der) - free(der); + free(der); if (sk) sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); if (sect) diff --git a/lib/libcrypto/asn1/t_x509.c b/lib/libcrypto/asn1/t_x509.c index efba93adeb8..f1c045e0e6f 100644 --- a/lib/libcrypto/asn1/t_x509.c +++ b/lib/libcrypto/asn1/t_x509.c @@ -245,8 +245,7 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) ret = 1; err: - if (m != NULL) - free(m); + free(m); return (ret); } @@ -294,8 +293,7 @@ int X509_ocspid_print (BIO *bp, X509 *x) return (1); err: - if (der != NULL) - free(der); + free(der); return (0); } diff --git a/lib/libcrypto/asn1/x_info.c b/lib/libcrypto/asn1/x_info.c index 2d1bf0d22d2..b17d7ace110 100644 --- a/lib/libcrypto/asn1/x_info.c +++ b/lib/libcrypto/asn1/x_info.c @@ -102,8 +102,7 @@ X509_INFO_free(X509_INFO *x) X509_CRL_free(x->crl); if (x->x_pkey != NULL) X509_PKEY_free(x->x_pkey); - if (x->enc_data != NULL) - free(x->enc_data); + free(x->enc_data); free(x); } diff --git a/lib/libcrypto/asn1/x_x509.c b/lib/libcrypto/asn1/x_x509.c index e93d97d2c41..7053bb87ebf 100644 --- a/lib/libcrypto/asn1/x_x509.c +++ b/lib/libcrypto/asn1/x_x509.c @@ -105,8 +105,7 @@ x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) break; case ASN1_OP_D2I_POST: - if (ret->name != NULL) - free(ret->name); + free(ret->name); ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0); break; @@ -123,8 +122,7 @@ x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free); ASIdentifiers_free(ret->rfc3779_asid); #endif - if (ret->name != NULL) - free(ret->name); + free(ret->name); ret->name = NULL; break; } diff --git a/lib/libcrypto/bio/b_sock.c b/lib/libcrypto/bio/b_sock.c index a9c4408a093..c7a10ca3482 100644 --- a/lib/libcrypto/bio/b_sock.c +++ b/lib/libcrypto/bio/b_sock.c @@ -435,8 +435,7 @@ again: } ret = 1; err: - if (str != NULL) - free(str); + free(str); if ((ret == 0) && (s != -1)) { close(s); s = -1; diff --git a/lib/libcrypto/bio/bf_buff.c b/lib/libcrypto/bio/bf_buff.c index e96da40a58a..0866c8c7a3e 100644 --- a/lib/libcrypto/bio/bf_buff.c +++ b/lib/libcrypto/bio/bf_buff.c @@ -130,10 +130,8 @@ buffer_free(BIO *a) if (a == NULL) return (0); b = (BIO_F_BUFFER_CTX *)a->ptr; - if (b->ibuf != NULL) - free(b->ibuf); - if (b->obuf != NULL) - free(b->obuf); + free(b->ibuf); + free(b->obuf); free(a->ptr); a->ptr = NULL; a->init = 0; @@ -342,8 +340,7 @@ buffer_ctrl(BIO *b, int cmd, long num, void *ptr) p1 = malloc((int)num); if (p1 == NULL) goto malloc_error; - if (ctx->ibuf != NULL) - free(ctx->ibuf); + free(ctx->ibuf); ctx->ibuf = p1; } ctx->ibuf_off = 0; diff --git a/lib/libcrypto/bio/bf_lbuf.c b/lib/libcrypto/bio/bf_lbuf.c index 54c370d0380..42c0e1dca59 100644 --- a/lib/libcrypto/bio/bf_lbuf.c +++ b/lib/libcrypto/bio/bf_lbuf.c @@ -131,8 +131,7 @@ linebuffer_free(BIO *a) if (a == NULL) return (0); b = (BIO_LINEBUFFER_CTX *)a->ptr; - if (b->obuf != NULL) - free(b->obuf); + free(b->obuf); free(a->ptr); a->ptr = NULL; a->init = 0; diff --git a/lib/libcrypto/bio/bf_nbio.c b/lib/libcrypto/bio/bf_nbio.c index 5a0f6b276a5..9b0ec7d41f9 100644 --- a/lib/libcrypto/bio/bf_nbio.c +++ b/lib/libcrypto/bio/bf_nbio.c @@ -119,8 +119,7 @@ nbiof_free(BIO *a) { if (a == NULL) return (0); - if (a->ptr != NULL) - free(a->ptr); + free(a->ptr); a->ptr = NULL; a->init = 0; a->flags = 0; diff --git a/lib/libcrypto/bio/bss_acpt.c b/lib/libcrypto/bio/bss_acpt.c index 943d3d9d961..d246aba6814 100644 --- a/lib/libcrypto/bio/bss_acpt.c +++ b/lib/libcrypto/bio/bss_acpt.c @@ -148,10 +148,8 @@ BIO_ACCEPT_free(BIO_ACCEPT *a) if (a == NULL) return; - if (a->param_addr != NULL) - free(a->param_addr); - if (a->addr != NULL) - free(a->addr); + free(a->param_addr); + free(a->addr); if (a->bio_chain != NULL) BIO_free(a->bio_chain); free(a); @@ -352,8 +350,7 @@ acpt_ctrl(BIO *b, int cmd, long num, void *ptr) if (ptr != NULL) { if (num == 0) { b->init = 1; - if (data->param_addr != NULL) - free(data->param_addr); + free(data->param_addr); data->param_addr = BUF_strdup(ptr); } else if (num == 1) { data->accept_nbio = (ptr != NULL); diff --git a/lib/libcrypto/bio/bss_bio.c b/lib/libcrypto/bio/bss_bio.c index eda2e2a55c2..519002beed7 100644 --- a/lib/libcrypto/bio/bss_bio.c +++ b/lib/libcrypto/bio/bss_bio.c @@ -160,12 +160,8 @@ bio_free(BIO *bio) if (b->peer) bio_destroy_pair(bio); - if (b->buf != NULL) { - free(b->buf); - } - + free(b->buf); free(b); - return 1; } diff --git a/lib/libcrypto/bio/bss_conn.c b/lib/libcrypto/bio/bss_conn.c index 7ed8f1fe31e..a31e5a170bb 100644 --- a/lib/libcrypto/bio/bss_conn.c +++ b/lib/libcrypto/bio/bss_conn.c @@ -147,8 +147,7 @@ conn_state(BIO *b, BIO_CONNECT *c) *q = '\0'; break; } - if (c->param_port != NULL) - free(c->param_port); + free(c->param_port); c->param_port = BUF_strdup(p); } } @@ -315,10 +314,8 @@ BIO_CONNECT_free(BIO_CONNECT *a) if (a == NULL) return; - if (a->param_hostname != NULL) - free(a->param_hostname); - if (a->param_port != NULL) - free(a->param_port); + free(a->param_hostname); + free(a->param_port); free(a); } @@ -469,12 +466,10 @@ conn_ctrl(BIO *b, int cmd, long num, void *ptr) if (ptr != NULL) { b->init = 1; if (num == 0) { - if (data->param_hostname != NULL) - free(data->param_hostname); + free(data->param_hostname); data->param_hostname = BUF_strdup(ptr); } else if (num == 1) { - if (data->param_port != NULL) - free(data->param_port); + free(data->param_port); data->param_port = BUF_strdup(ptr); } else if (num == 2) { char buf[16]; @@ -482,8 +477,7 @@ conn_ctrl(BIO *b, int cmd, long num, void *ptr) snprintf(buf, sizeof buf, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); - if (data->param_hostname != NULL) - free(data->param_hostname); + free(data->param_hostname); data->param_hostname = BUF_strdup(buf); memcpy(&(data->ip[0]), ptr, 4); } else if (num == 3) { @@ -491,8 +485,7 @@ conn_ctrl(BIO *b, int cmd, long num, void *ptr) snprintf(buf, sizeof buf, "%d", *(int *)ptr); - if (data->param_port != NULL) - free(data->param_port); + free(data->param_port); data->param_port = BUF_strdup(buf); data->port= *(int *)ptr; } diff --git a/lib/libcrypto/bio/bss_dgram.c b/lib/libcrypto/bio/bss_dgram.c index 8f7439c51e6..9160fe40186 100644 --- a/lib/libcrypto/bio/bss_dgram.c +++ b/lib/libcrypto/bio/bss_dgram.c @@ -217,8 +217,7 @@ dgram_free(BIO *a) return 0; data = (bio_dgram_data *)a->ptr; - if (data != NULL) - free(data); + free(data); return (1); } @@ -830,8 +829,7 @@ dgram_sctp_free(BIO *a) return 0; data = (bio_dgram_sctp_data *)a->ptr; - if (data != NULL) - free(data); + free(data); return (1); } diff --git a/lib/libcrypto/bn/bn_print.c b/lib/libcrypto/bn/bn_print.c index ea5fa5c3dae..ad3a847f01b 100644 --- a/lib/libcrypto/bn/bn_print.c +++ b/lib/libcrypto/bn/bn_print.c @@ -157,8 +157,7 @@ BN_bn2dec(const BIGNUM *a) ok = 1; err: - if (bn_data != NULL) - free(bn_data); + free(bn_data); if (t != NULL) BN_free(t); if (!ok && buf) { diff --git a/lib/libcrypto/conf/conf_api.c b/lib/libcrypto/conf/conf_api.c index 98e058dad45..41c5b05fcbe 100644 --- a/lib/libcrypto/conf/conf_api.c +++ b/lib/libcrypto/conf/conf_api.c @@ -300,8 +300,7 @@ err: if (!ok) { if (sk != NULL) sk_CONF_VALUE_free(sk); - if (v != NULL) - free(v); + free(v); v = NULL; } return (v); diff --git a/lib/libcrypto/conf/conf_def.c b/lib/libcrypto/conf/conf_def.c index b3c75e1a9e5..b550623e57c 100644 --- a/lib/libcrypto/conf/conf_def.c +++ b/lib/libcrypto/conf/conf_def.c @@ -416,15 +416,13 @@ again: } if (buff != NULL) BUF_MEM_free(buff); - if (section != NULL) - free(section); + free(section); return (1); err: if (buff != NULL) BUF_MEM_free(buff); - if (section != NULL) - free(section); + free(section); if (line != NULL) *line = eline; ERR_asprintf_error_data("line %ld", eline); @@ -433,12 +431,9 @@ err: conf->data = NULL; } if (v != NULL) { - if (v->name != NULL) - free(v->name); - if (v->value != NULL) - free(v->value); - if (v != NULL) - free(v); + free(v->name); + free(v->value); + free(v); } return (0); } @@ -615,8 +610,7 @@ str_copy(CONF *conf, char *section, char **pto, char *from) buf->data[to++] = *(from++); } buf->data[to]='\0'; - if (*pto != NULL) - free(*pto); + free(*pto); *pto = buf->data; free(buf); return (1); diff --git a/lib/libcrypto/dh/dh_ameth.c b/lib/libcrypto/dh/dh_ameth.c index 40e0202bff1..119ac615a6e 100644 --- a/lib/libcrypto/dh/dh_ameth.c +++ b/lib/libcrypto/dh/dh_ameth.c @@ -275,8 +275,7 @@ static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) return 1; err: - if (dp != NULL) - free(dp); + free(dp); if (params != NULL) ASN1_STRING_free(params); if (prkey != NULL) diff --git a/lib/libcrypto/dsa/dsa_ameth.c b/lib/libcrypto/dsa/dsa_ameth.c index 16617d40f5b..e2c3980e565 100644 --- a/lib/libcrypto/dsa/dsa_ameth.c +++ b/lib/libcrypto/dsa/dsa_ameth.c @@ -342,8 +342,7 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) return 1; err: - if (dp != NULL) - free(dp); + free(dp); if (params != NULL) ASN1_STRING_free(params); if (prkey != NULL) diff --git a/lib/libcrypto/dso/dso_dlfcn.c b/lib/libcrypto/dso/dso_dlfcn.c index bebfdcdbc41..87ebdb660d3 100644 --- a/lib/libcrypto/dso/dso_dlfcn.c +++ b/lib/libcrypto/dso/dso_dlfcn.c @@ -146,8 +146,7 @@ dlfcn_load(DSO *dso) err: /* Cleanup! */ - if (filename != NULL) - free(filename); + free(filename); if (ptr != NULL) dlclose(ptr); return (0); diff --git a/lib/libcrypto/dso/dso_lib.c b/lib/libcrypto/dso/dso_lib.c index 3859be7b42f..fa1c3c2b54c 100644 --- a/lib/libcrypto/dso/dso_lib.c +++ b/lib/libcrypto/dso/dso_lib.c @@ -156,11 +156,8 @@ DSO_free(DSO *dso) } sk_void_free(dso->meth_data); - if (dso->filename != NULL) - free(dso->filename); - if (dso->loaded_filename != NULL) - free(dso->loaded_filename); - + free(dso->filename); + free(dso->loaded_filename); free(dso); return (1); } diff --git a/lib/libcrypto/ec/ec_ameth.c b/lib/libcrypto/ec/ec_ameth.c index b41879c4315..ec074329f27 100644 --- a/lib/libcrypto/ec/ec_ameth.c +++ b/lib/libcrypto/ec/ec_ameth.c @@ -492,8 +492,7 @@ err: BN_free(order); if (ctx) BN_CTX_free(ctx); - if (buffer != NULL) - free(buffer); + free(buffer); return (ret); } diff --git a/lib/libcrypto/ec/ec_asn1.c b/lib/libcrypto/ec/ec_asn1.c index 2409cd0886c..342db2a992a 100644 --- a/lib/libcrypto/ec/ec_asn1.c +++ b/lib/libcrypto/ec/ec_asn1.c @@ -805,8 +805,7 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) } /* extract seed (optional) */ if (params->curve->seed != NULL) { - if (ret->seed != NULL) - free(ret->seed); + free(ret->seed); if (!(ret->seed = malloc(params->curve->seed->length))) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE); diff --git a/lib/libcrypto/ec/ec_mult.c b/lib/libcrypto/ec/ec_mult.c index 0fd0cab2f1a..8894a8f907e 100644 --- a/lib/libcrypto/ec/ec_mult.c +++ b/lib/libcrypto/ec/ec_mult.c @@ -683,10 +683,8 @@ err: BN_CTX_free(new_ctx); if (tmp != NULL) EC_POINT_free(tmp); - if (wsize != NULL) - free(wsize); - if (wNAF_len != NULL) - free(wNAF_len); + free(wsize); + free(wNAF_len); if (wNAF != NULL) { signed char **w; @@ -698,12 +696,9 @@ err: if (val != NULL) { for (v = val; *v != NULL; v++) EC_POINT_clear_free(*v); - free(val); } - if (val_sub != NULL) { - free(val_sub); - } + free(val_sub); return ret; } diff --git a/lib/libcrypto/ec/eck_prn.c b/lib/libcrypto/ec/eck_prn.c index 3f2973e5b65..60b00fddb3a 100644 --- a/lib/libcrypto/ec/eck_prn.c +++ b/lib/libcrypto/ec/eck_prn.c @@ -325,8 +325,7 @@ err: BN_free(cofactor); if (ctx) BN_CTX_free(ctx); - if (buffer != NULL) - free(buffer); + free(buffer); return (ret); } diff --git a/lib/libcrypto/ec/ecp_nistp224.c b/lib/libcrypto/ec/ecp_nistp224.c index 6e9b9fac3ca..afe25853e6b 100644 --- a/lib/libcrypto/ec/ecp_nistp224.c +++ b/lib/libcrypto/ec/ecp_nistp224.c @@ -1546,12 +1546,9 @@ err: EC_POINT_free(generator); if (new_ctx != NULL) BN_CTX_free(new_ctx); - if (secrets != NULL) - free(secrets); - if (pre_comp != NULL) - free(pre_comp); - if (tmp_felems != NULL) - free(tmp_felems); + free(secrets); + free(pre_comp); + free(tmp_felems); return ret; } diff --git a/lib/libcrypto/ec/ecp_nistp256.c b/lib/libcrypto/ec/ecp_nistp256.c index b2398e106c0..7fe7be27de4 100644 --- a/lib/libcrypto/ec/ecp_nistp256.c +++ b/lib/libcrypto/ec/ecp_nistp256.c @@ -2101,12 +2101,9 @@ err: EC_POINT_free(generator); if (new_ctx != NULL) BN_CTX_free(new_ctx); - if (secrets != NULL) - free(secrets); - if (pre_comp != NULL) - free(pre_comp); - if (tmp_smallfelems != NULL) - free(tmp_smallfelems); + free(secrets); + free(pre_comp); + free(tmp_smallfelems); return ret; } diff --git a/lib/libcrypto/ec/ecp_nistp521.c b/lib/libcrypto/ec/ecp_nistp521.c index 083e017cdc2..5d5a747ee85 100644 --- a/lib/libcrypto/ec/ecp_nistp521.c +++ b/lib/libcrypto/ec/ecp_nistp521.c @@ -1988,12 +1988,9 @@ err: EC_POINT_free(generator); if (new_ctx != NULL) BN_CTX_free(new_ctx); - if (secrets != NULL) - free(secrets); - if (pre_comp != NULL) - free(pre_comp); - if (tmp_felems != NULL) - free(tmp_felems); + free(secrets); + free(pre_comp); + free(tmp_felems); return ret; } diff --git a/lib/libcrypto/engine/eng_dyn.c b/lib/libcrypto/engine/eng_dyn.c index f59d768350f..e2de4603eea 100644 --- a/lib/libcrypto/engine/eng_dyn.c +++ b/lib/libcrypto/engine/eng_dyn.c @@ -169,10 +169,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) - free((void*)ctx->DYNAMIC_LIBNAME); - if(ctx->engine_id) - free((void*)ctx->engine_id); + free((void *)ctx->DYNAMIC_LIBNAME); + free((void *)ctx->engine_id); if(ctx->dirs) sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str); free(ctx); @@ -335,8 +333,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) - free((void*)ctx->DYNAMIC_LIBNAME); + free((void *)ctx->DYNAMIC_LIBNAME); if(p) ctx->DYNAMIC_LIBNAME = BUF_strdup(p); else @@ -349,8 +346,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) - free((void*)ctx->engine_id); + free((void *)ctx->engine_id); if(p) ctx->engine_id = BUF_strdup(p); else diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index e31940da45e..a71959222ff 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -294,8 +294,7 @@ 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) - free(aop); + free(aop); } } o->flags &= ~(ASN1_OBJECT_FLAG_DYNAMIC | @@ -308,10 +307,8 @@ err2: OBJerr(OBJ_F_OBJ_ADD_OBJECT, ERR_R_MALLOC_FAILURE); err: for (i = ADDED_DATA; i <= ADDED_NID; i++) - if (ao[i] != NULL) - free(ao[i]); - if (o != NULL) - free(o); + free(ao[i]); + free(o); return (NID_undef); } diff --git a/lib/libcrypto/objects/obj_lib.c b/lib/libcrypto/objects/obj_lib.c index 57f0b28cc04..25bc8fb5eea 100644 --- a/lib/libcrypto/objects/obj_lib.c +++ b/lib/libcrypto/objects/obj_lib.c @@ -114,14 +114,10 @@ OBJ_dup(const ASN1_OBJECT *o) err: OBJerr(OBJ_F_OBJ_DUP, ERR_R_MALLOC_FAILURE); - if (ln != NULL) - free(ln); - if (sn != NULL) - free(sn); - if (data != NULL) - free(data); - if (r != NULL) - free(r); + free(ln); + free(sn); + free(data); + free(r); return (NULL); } diff --git a/lib/libcrypto/pem/pem_info.c b/lib/libcrypto/pem/pem_info.c index 40600e30f3e..7605c7653c2 100644 --- a/lib/libcrypto/pem/pem_info.c +++ b/lib/libcrypto/pem/pem_info.c @@ -256,12 +256,9 @@ start: } else { /* unknown */ } - if (name != NULL) - free(name); - if (header != NULL) - free(header); - if (data != NULL) - free(data); + free(name); + free(header); + free(data); name = NULL; header = NULL; data = NULL; @@ -291,12 +288,9 @@ err: ret = NULL; } - if (name != NULL) - free(name); - if (header != NULL) - free(header); - if (data != NULL) - free(data); + free(name); + free(header); + free(data); return (ret); } diff --git a/lib/libcrypto/pem/pem_seal.c b/lib/libcrypto/pem/pem_seal.c index a7b93792235..e6e73dd23db 100644 --- a/lib/libcrypto/pem/pem_seal.c +++ b/lib/libcrypto/pem/pem_seal.c @@ -113,8 +113,7 @@ PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type, ret = npubk; err: - if (s != NULL) - free(s); + free(s); OPENSSL_cleanse(key, EVP_MAX_KEY_LENGTH); return (ret); } @@ -182,8 +181,7 @@ 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) - free(s); + free(s); return (ret); } #endif diff --git a/lib/libcrypto/pem/pem_sign.c b/lib/libcrypto/pem/pem_sign.c index 8a6bcc8d8df..bfe7823e3d5 100644 --- a/lib/libcrypto/pem/pem_sign.c +++ b/lib/libcrypto/pem/pem_sign.c @@ -100,7 +100,6 @@ PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, err: /* ctx has been zeroed by EVP_SignFinal() */ - if (m != NULL) - free(m); + free(m); return (ret); } diff --git a/lib/libcrypto/stack/stack.c b/lib/libcrypto/stack/stack.c index 7eb00fd6e40..80ad087753f 100644 --- a/lib/libcrypto/stack/stack.c +++ b/lib/libcrypto/stack/stack.c @@ -297,8 +297,7 @@ sk_free(_STACK *st) { if (st == NULL) return; - if (st->data != NULL) - free(st->data); + free(st->data); free(st); } diff --git a/lib/libcrypto/txt_db/txt_db.c b/lib/libcrypto/txt_db/txt_db.c index e29a60316ae..3f7fea6d2ae 100644 --- a/lib/libcrypto/txt_db/txt_db.c +++ b/lib/libcrypto/txt_db/txt_db.c @@ -178,12 +178,9 @@ err: if (ret != NULL) { if (ret->data != NULL) sk_OPENSSL_PSTRING_free(ret->data); - if (ret->index != NULL) - free(ret->index); - if (ret->qual != NULL) - free(ret->qual); - if (ret != NULL) - free(ret); + free(ret->index); + free(ret->qual); + free(ret); } return (NULL); } else @@ -350,8 +347,7 @@ TXT_DB_free(TXT_DB *db) lh_OPENSSL_STRING_free(db->index[i]); free(db->index); } - if (db->qual != NULL) - free(db->qual); + free(db->qual); if (db->data != NULL) { for (i = sk_OPENSSL_PSTRING_num(db->data) - 1; i >= 0; i--) { /* check if any 'fields' have been allocated @@ -361,8 +357,7 @@ TXT_DB_free(TXT_DB *db) if (max == NULL) /* new row */ { for (n = 0; n < db->num_fields; n++) - if (p[n] != NULL) - free(p[n]); + free(p[n]); } else { for (n = 0; n < db->num_fields; n++) { if (((p[n] < (char *)p) || diff --git a/lib/libcrypto/x509v3/v3_prn.c b/lib/libcrypto/x509v3/v3_prn.c index ff08534f9a0..d06932aef1b 100644 --- a/lib/libcrypto/x509v3/v3_prn.c +++ b/lib/libcrypto/x509v3/v3_prn.c @@ -143,8 +143,7 @@ X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent) err: sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); - if (value) - free(value); + free(value); if (method->it) ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it)); else diff --git a/lib/libcrypto/x509v3/v3_utl.c b/lib/libcrypto/x509v3/v3_utl.c index 0b389807dd9..3134feff21f 100644 --- a/lib/libcrypto/x509v3/v3_utl.c +++ b/lib/libcrypto/x509v3/v3_utl.c @@ -103,12 +103,9 @@ X509V3_add_value(const char *name, const char *value, err: X509V3err(X509V3_F_X509V3_ADD_VALUE, ERR_R_MALLOC_FAILURE); - if (vtmp) - free(vtmp); - if (tname) - free(tname); - if (tvalue) - free(tvalue); + free(vtmp); + free(tname); + free(tvalue); return 0; } @@ -126,12 +123,9 @@ X509V3_conf_free(CONF_VALUE *conf) { if (!conf) return; - if (conf->name) - free(conf->name); - if (conf->value) - free(conf->value); - if (conf->section) - free(conf->section); + free(conf->name); + free(conf->value); + free(conf->section); free(conf); } |