aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-05-01 10:15:18 -0400
committerRich Salz <rsalz@openssl.org>2015-05-01 10:15:18 -0400
commitefa7dd64443f246004751bdaa5671bf6836e07ff (patch)
treedf55d807a97d046ce17eb12adca78ea36a6038fa
parentb548a1f11c06ccdfa4f52a539912d22d77ee309e (diff)
downloadopenssl-efa7dd64443f246004751bdaa5671bf6836e07ff.tar.gz
free NULL cleanup 11
Don't check for NULL before calling free functions. This gets: ERR_STATE_free ENGINE_free DSO_free CMAC_CTX_free COMP_CTX_free CONF_free NCONF_free NCONF_free_data _CONF_free_data A sk_free use within OBJ_sigid_free TS_TST_INFO_free (rest of TS_ API was okay) Doc update for UI_free (all uses were fine) X509V3_conf_free X509V3_section_free X509V3_string_free Reviewed-by: Richard Levitte <levitte@openssl.org>
-rw-r--r--apps/apps.c3
-rw-r--r--apps/req.c3
-rw-r--r--crypto/asn1/asn1_gen.c3
-rw-r--r--crypto/asn1/asn_mstbl.c3
-rw-r--r--crypto/cmac/cm_ameth.c3
-rw-r--r--crypto/cmac/cmac.c2
-rw-r--r--crypto/comp/c_zlib.c3
-rw-r--r--crypto/conf/conf_api.c18
-rw-r--r--crypto/conf/conf_mod.c8
-rw-r--r--crypto/dso/dso_lib.c6
-rw-r--r--crypto/engine/eng_cnf.c3
-rw-r--r--crypto/engine/eng_dyn.c3
-rw-r--r--crypto/engine/eng_lib.c8
-rw-r--r--crypto/engine/eng_table.c2
-rw-r--r--crypto/err/err.c6
-rw-r--r--crypto/objects/obj_xref.c12
-rw-r--r--crypto/ts/ts_asn1.c6
-rw-r--r--crypto/ts/ts_conf.c3
-rw-r--r--demos/engines/cluster_labs/hw_cluster_labs.c4
-rw-r--r--demos/engines/ibmca/hw_ibmca.c4
-rw-r--r--demos/engines/zencod/hw_zencod.c4
-rw-r--r--engines/e_4758cca.c3
-rw-r--r--engines/e_aep.c3
-rw-r--r--engines/e_atalla.c3
-rw-r--r--engines/e_chil.c3
-rw-r--r--engines/e_cswift.c6
-rw-r--r--engines/e_sureware.c3
-rw-r--r--engines/e_ubsec.c3
-rw-r--r--ssl/s3_enc.c12
-rw-r--r--ssl/ssl_lib.c12
-rw-r--r--ssl/t1_enc.c12
-rw-r--r--test/enginetest.c21
32 files changed, 67 insertions, 121 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 46cc5a05e7..f2a17a4633 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1612,8 +1612,7 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
}
err:
- if (dbattr_conf)
- NCONF_free(dbattr_conf);
+ NCONF_free(dbattr_conf);
TXT_DB_free(tmpdb);
BIO_free_all(in);
return retdb;
diff --git a/apps/req.c b/apps/req.c
index 4ff3b246fe..e8e18ecdde 100644
--- a/apps/req.c
+++ b/apps/req.c
@@ -883,8 +883,7 @@ int req_main(int argc, char **argv)
if (sigopts)
sk_OPENSSL_STRING_free(sigopts);
#ifndef OPENSSL_NO_ENGINE
- if (gen_eng)
- ENGINE_free(gen_eng);
+ ENGINE_free(gen_eng);
#endif
OPENSSL_free(keyalgstr);
X509_REQ_free(req);
diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c
index 6756c67a47..549bc5ef36 100644
--- a/crypto/asn1/asn1_gen.c
+++ b/crypto/asn1/asn1_gen.c
@@ -511,8 +511,7 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
OPENSSL_free(der);
sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
- if (sect)
- X509V3_section_free(cnf, sect);
+ X509V3_section_free(cnf, sect);
return ret;
}
diff --git a/crypto/asn1/asn_mstbl.c b/crypto/asn1/asn_mstbl.c
index 889cbe49c8..94ffbd8ada 100644
--- a/crypto/asn1/asn_mstbl.c
+++ b/crypto/asn1/asn_mstbl.c
@@ -154,7 +154,6 @@ static int do_tcreate(char *value, char *name)
if (!rv)
ASN1err(ASN1_F_DO_TCREATE, ERR_R_MALLOC_FAILURE);
}
- if (lst)
- sk_CONF_VALUE_pop_free(lst, X509V3_conf_free);
+ sk_CONF_VALUE_pop_free(lst, X509V3_conf_free);
return rv;
}
diff --git a/crypto/cmac/cm_ameth.c b/crypto/cmac/cm_ameth.c
index 98634c99e9..07853a63d3 100644
--- a/crypto/cmac/cm_ameth.c
+++ b/crypto/cmac/cm_ameth.c
@@ -70,8 +70,7 @@ static int cmac_size(const EVP_PKEY *pkey)
static void cmac_key_free(EVP_PKEY *pkey)
{
CMAC_CTX *cmctx = (CMAC_CTX *)pkey->pkey.ptr;
- if (cmctx)
- CMAC_CTX_free(cmctx);
+ CMAC_CTX_free(cmctx);
}
const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
diff --git a/crypto/cmac/cmac.c b/crypto/cmac/cmac.c
index 19018480f2..5e8fdc399b 100644
--- a/crypto/cmac/cmac.c
+++ b/crypto/cmac/cmac.c
@@ -115,6 +115,8 @@ EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx)
void CMAC_CTX_free(CMAC_CTX *ctx)
{
+ if (!ctx)
+ return;
CMAC_CTX_cleanup(ctx);
OPENSSL_free(ctx);
}
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c
index 4508e7f634..334c78f296 100644
--- a/crypto/comp/c_zlib.c
+++ b/crypto/comp/c_zlib.c
@@ -289,8 +289,7 @@ COMP_METHOD *COMP_zlib(void)
void COMP_zlib_cleanup(void)
{
#ifdef ZLIB_SHARED
- if (zlib_dso)
- DSO_free(zlib_dso);
+ DSO_free(zlib_dso);
#endif
}
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index b41564b680..59808a301b 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -241,8 +241,7 @@ static void value_free_stack_doall(CONF_VALUE *a)
OPENSSL_free(vv->name);
OPENSSL_free(vv);
}
- if (sk != NULL)
- sk_CONF_VALUE_free(sk);
+ sk_CONF_VALUE_free(sk);
OPENSSL_free(a->section);
OPENSSL_free(a);
}
@@ -251,7 +250,7 @@ static void value_free_stack_doall(CONF_VALUE *a)
CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
{
STACK_OF(CONF_VALUE) *sk = NULL;
- int ok = 0, i;
+ int i;
CONF_VALUE *v = NULL, *vv;
if ((sk = sk_CONF_VALUE_new_null()) == NULL)
@@ -268,13 +267,10 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section)
vv = lh_CONF_VALUE_insert(conf->data, v);
OPENSSL_assert(vv == NULL);
- ok = 1;
+ return v;
+
err:
- if (!ok) {
- if (sk != NULL)
- sk_CONF_VALUE_free(sk);
- OPENSSL_free(v);
- v = NULL;
- }
- return (v);
+ sk_CONF_VALUE_free(sk);
+ OPENSSL_free(v);
+ return NULL;
}
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
index ce2b177873..18fe38b302 100644
--- a/crypto/conf/conf_mod.c
+++ b/crypto/conf/conf_mod.c
@@ -266,8 +266,7 @@ static CONF_MODULE *module_load_dso(const CONF *cnf, char *name, char *value,
return md;
err:
- if (dso)
- DSO_free(dso);
+ DSO_free(dso);
CONFerr(CONF_F_MODULE_LOAD_DSO, errcode);
ERR_add_error_data(4, "module=", name, ", path=", path);
return NULL;
@@ -422,8 +421,7 @@ void CONF_modules_unload(int all)
/* unload a single module */
static void module_free(CONF_MODULE *md)
{
- if (md->dso)
- DSO_free(md->dso);
+ DSO_free(md->dso);
OPENSSL_free(md->name);
OPENSSL_free(md);
}
@@ -445,6 +443,8 @@ void CONF_modules_finish(void)
static void module_finish(CONF_IMODULE *imod)
{
+ if (!imod)
+ return;
if (imod->pmod->finish)
imod->pmod->finish(imod);
imod->pmod->links--;
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c
index a33a8a85bb..99701d15d4 100644
--- a/crypto/dso/dso_lib.c
+++ b/crypto/dso/dso_lib.c
@@ -133,10 +133,8 @@ int DSO_free(DSO *dso)
{
int i;
- if (dso == NULL) {
- DSOerr(DSO_F_DSO_FREE, ERR_R_PASSED_NULL_PARAMETER);
- return (0);
- }
+ if (dso == NULL)
+ return (1);
i = CRYPTO_add(&dso->references, -1, CRYPTO_LOCK_DSO);
#ifdef REF_PRINT
diff --git a/crypto/engine/eng_cnf.c b/crypto/engine/eng_cnf.c
index f09bec4e9a..e84281f22e 100644
--- a/crypto/engine/eng_cnf.c
+++ b/crypto/engine/eng_cnf.c
@@ -194,8 +194,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
", name=", ecmd->name,
", value=", ecmd->value);
}
- if (e)
- ENGINE_free(e);
+ ENGINE_free(e);
return ret;
}
diff --git a/crypto/engine/eng_dyn.c b/crypto/engine/eng_dyn.c
index 7dd3659e76..02590e026a 100644
--- a/crypto/engine/eng_dyn.c
+++ b/crypto/engine/eng_dyn.c
@@ -186,8 +186,7 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
{
if (ptr) {
dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr;
- if (ctx->dynamic_dso)
- DSO_free(ctx->dynamic_dso);
+ DSO_free(ctx->dynamic_dso);
OPENSSL_free(ctx->DYNAMIC_LIBNAME);
OPENSSL_free(ctx->engine_id);
if (ctx->dirs)
diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c
index 608344064e..64b0cadb90 100644
--- a/crypto/engine/eng_lib.c
+++ b/crypto/engine/eng_lib.c
@@ -108,16 +108,14 @@ int engine_free_util(ENGINE *e, int locked)
{
int i;
- if (e == NULL) {
- ENGINEerr(ENGINE_F_ENGINE_FREE_UTIL, ERR_R_PASSED_NULL_PARAMETER);
- return 0;
- }
+ if (e == NULL)
+ return 1;
if (locked)
i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE);
else
i = --e->struct_ref;
engine_ref_debug(e, 0, -1)
- if (i > 0)
+ if (i > 0)
return 1;
#ifdef REF_CHECK
if (i < 0) {
diff --git a/crypto/engine/eng_table.c b/crypto/engine/eng_table.c
index 53a6a25600..16eb771436 100644
--- a/crypto/engine/eng_table.c
+++ b/crypto/engine/eng_table.c
@@ -216,6 +216,8 @@ void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e)
static void int_cleanup_cb_doall(ENGINE_PILE *p)
{
+ if (!p)
+ return;
sk_ENGINE_free(p->sk);
if (p->funct)
engine_unlocked_finish(p->funct, 0);
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 9d58f38144..308504a8ed 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -409,8 +409,7 @@ static void int_thread_del_item(const ERR_STATE *d)
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
int_thread_release(&hash);
- if (p)
- ERR_STATE_free(p);
+ ERR_STATE_free(p);
}
#ifndef OPENSSL_NO_ERR
@@ -905,8 +904,7 @@ ERR_STATE *ERR_get_state(void)
* If a race occurred in this function and we came second, tmpp is
* the first one that we just replaced.
*/
- if (tmpp)
- ERR_STATE_free(tmpp);
+ ERR_STATE_free(tmpp);
}
return ret;
}
diff --git a/crypto/objects/obj_xref.c b/crypto/objects/obj_xref.c
index 97b305d213..b752a2c5be 100644
--- a/crypto/objects/obj_xref.c
+++ b/crypto/objects/obj_xref.c
@@ -184,14 +184,10 @@ static void sid_free(nid_triple *tt)
void OBJ_sigid_free(void)
{
- if (sig_app) {
- sk_nid_triple_pop_free(sig_app, sid_free);
- sig_app = NULL;
- }
- if (sigx_app) {
- sk_nid_triple_free(sigx_app);
- sigx_app = NULL;
- }
+ sk_nid_triple_pop_free(sig_app, sid_free);
+ sig_app = NULL;
+ sk_nid_triple_free(sigx_app);
+ sigx_app = NULL;
}
#ifdef OBJ_XREF_TEST
diff --git a/crypto/ts/ts_asn1.c b/crypto/ts/ts_asn1.c
index 7c741d9691..99b686f39d 100644
--- a/crypto/ts/ts_asn1.c
+++ b/crypto/ts/ts_asn1.c
@@ -189,8 +189,7 @@ static int ts_resp_set_tst_info(TS_RESP *a)
TSerr(TS_F_TS_RESP_SET_TST_INFO, TS_R_TOKEN_PRESENT);
return 0;
}
- if (a->tst_info != NULL)
- TS_TST_INFO_free(a->tst_info);
+ TS_TST_INFO_free(a->tst_info);
a->tst_info = PKCS7_to_TS_TST_INFO(a->token);
if (!a->tst_info) {
TSerr(TS_F_TS_RESP_SET_TST_INFO,
@@ -212,8 +211,7 @@ static int ts_resp_cb(int op, ASN1_VALUE **pval, const ASN1_ITEM *it,
if (op == ASN1_OP_NEW_POST) {
ts_resp->tst_info = NULL;
} else if (op == ASN1_OP_FREE_POST) {
- if (ts_resp->tst_info != NULL)
- TS_TST_INFO_free(ts_resp->tst_info);
+ TS_TST_INFO_free(ts_resp->tst_info);
} else if (op == ASN1_OP_D2I_POST) {
if (ts_resp_set_tst_info(ts_resp) == 0)
return 0;
diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c
index 4716b2336d..2b85660209 100644
--- a/crypto/ts/ts_conf.c
+++ b/crypto/ts/ts_conf.c
@@ -230,8 +230,7 @@ int TS_CONF_set_default_engine(const char *name)
TSerr(TS_F_TS_CONF_SET_DEFAULT_ENGINE, TS_R_COULD_NOT_SET_ENGINE);
ERR_add_error_data(2, "engine:", name);
}
- if (e)
- ENGINE_free(e);
+ ENGINE_free(e);
return ret;
}
diff --git a/demos/engines/cluster_labs/hw_cluster_labs.c b/demos/engines/cluster_labs/hw_cluster_labs.c
index c58e548f16..918689c215 100644
--- a/demos/engines/cluster_labs/hw_cluster_labs.c
+++ b/demos/engines/cluster_labs/hw_cluster_labs.c
@@ -363,9 +363,7 @@ int cluster_labs_init(ENGINE *e)
err:
/* reset all pointers */
- if (cluster_labs_dso)
- DSO_free(cluster_labs_dso);
-
+ DSO_free(cluster_labs_dso);
cluster_labs_dso = NULL;
p_cl_engine_init = NULL;
p_cl_mod_exp = NULL;
diff --git a/demos/engines/ibmca/hw_ibmca.c b/demos/engines/ibmca/hw_ibmca.c
index 082246f92d..820abe862e 100644
--- a/demos/engines/ibmca/hw_ibmca.c
+++ b/demos/engines/ibmca/hw_ibmca.c
@@ -412,9 +412,7 @@ static int ibmca_init(ENGINE *e)
return 1;
err:
- if (ibmca_dso)
- DSO_free(ibmca_dso);
-
+ DSO_free(ibmca_dso);
p_icaOpenAdapter = NULL;
p_icaCloseAdapter = NULL;
p_icaRsaModExpo = NULL;
diff --git a/demos/engines/zencod/hw_zencod.c b/demos/engines/zencod/hw_zencod.c
index 0b72217465..773674f444 100644
--- a/demos/engines/zencod/hw_zencod.c
+++ b/demos/engines/zencod/hw_zencod.c
@@ -623,9 +623,7 @@ static int zencod_init(ENGINE *e)
return 1;
err:
- if (zencod_dso) {
- DSO_free(zencod_dso);
- }
+ DSO_free(zencod_dso);
zencod_dso = NULL;
ptr_zencod_bytes2bits = NULL;
ptr_zencod_bits2bytes = NULL;
diff --git a/engines/e_4758cca.c b/engines/e_4758cca.c
index 9c98129d98..e592cfb611 100644
--- a/engines/e_4758cca.c
+++ b/engines/e_4758cca.c
@@ -324,8 +324,7 @@ static int ibm_4758_cca_init(ENGINE *e)
return 1;
err:
- if (dso)
- DSO_free(dso);
+ DSO_free(dso);
dso = NULL;
# ifndef OPENSSL_NO_RSA
diff --git a/engines/e_aep.c b/engines/e_aep.c
index c86b34adbb..8a47f7d057 100644
--- a/engines/e_aep.c
+++ b/engines/e_aep.c
@@ -501,8 +501,7 @@ static int aep_init(ENGINE *e)
err:
- if (aep_dso)
- DSO_free(aep_dso);
+ DSO_free(aep_dso);
aep_dso = NULL;
p_AEP_OpenConnection = NULL;
diff --git a/engines/e_atalla.c b/engines/e_atalla.c
index e9a6134871..278cff427a 100644
--- a/engines/e_atalla.c
+++ b/engines/e_atalla.c
@@ -406,8 +406,7 @@ static int atalla_init(ENGINE *e)
/* Everything's fine. */
return 1;
err:
- if (atalla_dso)
- DSO_free(atalla_dso);
+ DSO_free(atalla_dso);
atalla_dso = NULL;
p_Atalla_GetHardwareConfig = NULL;
p_Atalla_RSAPrivateKeyOpFn = NULL;
diff --git a/engines/e_chil.c b/engines/e_chil.c
index 35352140af..75c15f69e2 100644
--- a/engines/e_chil.c
+++ b/engines/e_chil.c
@@ -622,8 +622,7 @@ static int hwcrhk_init(ENGINE *e)
# endif
return 1;
err:
- if (hwcrhk_dso)
- DSO_free(hwcrhk_dso);
+ DSO_free(hwcrhk_dso);
hwcrhk_dso = NULL;
p_hwcrhk_Init = NULL;
p_hwcrhk_Finish = NULL;
diff --git a/engines/e_cswift.c b/engines/e_cswift.c
index 0b4bfc503e..5dcee7cdc7 100644
--- a/engines/e_cswift.c
+++ b/engines/e_cswift.c
@@ -431,10 +431,8 @@ static int cswift_init(ENGINE *e)
/* Everything's fine. */
return 1;
err:
- if (cswift_dso) {
- DSO_free(cswift_dso);
- cswift_dso = NULL;
- }
+ DSO_free(cswift_dso);
+ cswift_dso = NULL;
p_CSwift_AcquireAccContext = NULL;
p_CSwift_AttachKeyParam = NULL;
p_CSwift_SimpleRequest = NULL;
diff --git a/engines/e_sureware.c b/engines/e_sureware.c
index 9e56a7d28e..7d8c147db7 100644
--- a/engines/e_sureware.c
+++ b/engines/e_sureware.c
@@ -560,8 +560,7 @@ static int surewarehk_init(ENGINE *e)
return 1;
err:
- if (surewarehk_dso)
- DSO_free(surewarehk_dso);
+ DSO_free(surewarehk_dso);
surewarehk_dso = NULL;
p_surewarehk_Init = NULL;
p_surewarehk_Finish = NULL;
diff --git a/engines/e_ubsec.c b/engines/e_ubsec.c
index c7eb892cf4..a44b0b2b4a 100644
--- a/engines/e_ubsec.c
+++ b/engines/e_ubsec.c
@@ -481,8 +481,7 @@ static int ubsec_init(ENGINE *e)
}
err:
- if (ubsec_dso)
- DSO_free(ubsec_dso);
+ DSO_free(ubsec_dso);
ubsec_dso = NULL;
p_UBSEC_ubsec_bytes_to_bits = NULL;
p_UBSEC_ubsec_bits_to_bytes = NULL;
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index df86f5b9f3..45de404894 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -259,10 +259,8 @@ int ssl3_change_cipher_state(SSL *s, int which)
}
#ifndef OPENSSL_NO_COMP
/* COMPRESS */
- if (s->expand != NULL) {
- COMP_CTX_free(s->expand);
- s->expand = NULL;
- }
+ COMP_CTX_free(s->expand);
+ s->expand = NULL;
if (comp != NULL) {
s->expand = COMP_CTX_new(comp);
if (s->expand == NULL) {
@@ -294,10 +292,8 @@ int ssl3_change_cipher_state(SSL *s, int which)
}
#ifndef OPENSSL_NO_COMP
/* COMPRESS */
- if (s->compress != NULL) {
- COMP_CTX_free(s->compress);
- s->compress = NULL;
- }
+ COMP_CTX_free(s->compress);
+ s->compress = NULL;
if (comp != NULL) {
s->compress = COMP_CTX_new(comp);
if (s->compress == NULL) {
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 5b56ac79e3..8eab3e9283 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -2860,14 +2860,10 @@ void ssl_clear_cipher_ctx(SSL *s)
s->enc_write_ctx = NULL;
}
#ifndef OPENSSL_NO_COMP
- if (s->expand != NULL) {
- COMP_CTX_free(s->expand);
- s->expand = NULL;
- }
- if (s->compress != NULL) {
- COMP_CTX_free(s->compress);
- s->compress = NULL;
- }
+ COMP_CTX_free(s->expand);
+ s->expand = NULL;
+ COMP_CTX_free(s->compress);
+ s->compress = NULL;
#endif
}
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c
index e87d4b3963..5c7fb86a70 100644
--- a/ssl/t1_enc.c
+++ b/ssl/t1_enc.c
@@ -385,10 +385,8 @@ int tls1_change_cipher_state(SSL *s, int which)
dd = s->enc_read_ctx;
mac_ctx = ssl_replace_hash(&s->read_hash, NULL);
#ifndef OPENSSL_NO_COMP
- if (s->expand != NULL) {
- COMP_CTX_free(s->expand);
- s->expand = NULL;
- }
+ COMP_CTX_free(s->expand);
+ s->expand = NULL;
if (comp != NULL) {
s->expand = COMP_CTX_new(comp->method);
if (s->expand == NULL) {
@@ -425,10 +423,8 @@ int tls1_change_cipher_state(SSL *s, int which)
} else
mac_ctx = ssl_replace_hash(&s->write_hash, NULL);
#ifndef OPENSSL_NO_COMP
- if (s->compress != NULL) {
- COMP_CTX_free(s->compress);
- s->compress = NULL;
- }
+ COMP_CTX_free(s->compress);
+ s->compress = NULL;
if (comp != NULL) {
s->compress = COMP_CTX_new(comp->method);
if (s->compress == NULL) {
diff --git a/test/enginetest.c b/test/enginetest.c
index ab7c0c00dd..2d9afaaed1 100644
--- a/test/enginetest.c
+++ b/test/enginetest.c
@@ -147,8 +147,7 @@ int main(int argc, char *argv[])
printf("Remove failed!\n");
goto end;
}
- if (ptr)
- ENGINE_free(ptr);
+ ENGINE_free(ptr);
display_engine_list();
if (!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) {
printf("Add failed!\n");
@@ -196,8 +195,7 @@ int main(int argc, char *argv[])
if (!ENGINE_remove(ptr))
printf("Remove failed!i - probably no hardware "
"support present.\n");
- if (ptr)
- ENGINE_free(ptr);
+ ENGINE_free(ptr);
display_engine_list();
if (!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) {
printf("Couldn't add and remove to an empty list!\n");
@@ -248,17 +246,12 @@ int main(int argc, char *argv[])
end:
if (to_return)
ERR_print_errors_fp(stderr);
- if (new_h1)
- ENGINE_free(new_h1);
- if (new_h2)
- ENGINE_free(new_h2);
- if (new_h3)
- ENGINE_free(new_h3);
- if (new_h4)
- ENGINE_free(new_h4);
+ ENGINE_free(new_h1);
+ ENGINE_free(new_h2);
+ ENGINE_free(new_h3);
+ ENGINE_free(new_h4);
for (loop = 0; loop < 512; loop++)
- if (block[loop])
- ENGINE_free(block[loop]);
+ ENGINE_free(block[loop]);
ENGINE_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_free_strings();