aboutsummaryrefslogtreecommitdiff
path: root/engines
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 /engines
parent33fbca83dcd05b77f807fab205c4523b8cfe85b5 (diff)
downloadopenssl-b548a1f11c06ccdfa4f52a539912d22d77ee309e.zip
openssl-b548a1f11c06ccdfa4f52a539912d22d77ee309e.tar.gz
openssl-b548a1f11c06ccdfa4f52a539912d22d77ee309e.tar.bz2
free null cleanup finale
Don't check for NULL before calling OPENSSL_free Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'engines')
-rw-r--r--engines/ccgost/gost_ameth.c4
-rw-r--r--engines/ccgost/gost_ctl.c16
-rw-r--r--engines/ccgost/gost_pmeth.c4
-rw-r--r--engines/e_4758cca.c9
-rw-r--r--engines/e_aep.c3
-rw-r--r--engines/e_atalla.c3
-rw-r--r--engines/e_capi.c48
-rw-r--r--engines/e_chil.c3
-rw-r--r--engines/e_cswift.c18
-rw-r--r--engines/e_nuron.c3
-rw-r--r--engines/e_ubsec.c3
11 files changed, 40 insertions, 74 deletions
diff --git a/engines/ccgost/gost_ameth.c b/engines/ccgost/gost_ameth.c
index 0b694f5..b6c47f0 100644
--- a/engines/ccgost/gost_ameth.c
+++ b/engines/ccgost/gost_ameth.c
@@ -848,9 +848,7 @@ static int pkey_bits_gost(const EVP_PKEY *pk)
/* ---------------------- ASN1 METHOD for GOST MAC -------------------*/
static void mackey_free_gost(EVP_PKEY *pk)
{
- if (pk->pkey.ptr) {
- OPENSSL_free(pk->pkey.ptr);
- }
+ OPENSSL_free(pk->pkey.ptr);
}
static int mac_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)
diff --git a/engines/ccgost/gost_ctl.c b/engines/ccgost/gost_ctl.c
index 6c93c45..31b95a0 100644
--- a/engines/ccgost/gost_ctl.c
+++ b/engines/ccgost/gost_ctl.c
@@ -38,11 +38,11 @@ const ENGINE_CMD_DEFN gost_cmds[] = {
void gost_param_free()
{
int i;
- for (i = 0; i <= GOST_PARAM_MAX; i++)
- if (gost_params[i] != NULL) {
- OPENSSL_free(gost_params[i]);
- gost_params[i] = NULL;
- }
+
+ for (i = 0; i <= GOST_PARAM_MAX; i++) {
+ OPENSSL_free(gost_params[i]);
+ gost_params[i] = NULL;
+ }
}
@@ -66,8 +66,7 @@ const char *get_gost_engine_param(int param)
}
tmp = getenv(gost_envnames[param]);
if (tmp) {
- if (gost_params[param])
- OPENSSL_free(gost_params[param]);
+ OPENSSL_free(gost_params[param]);
gost_params[param] = BUF_strdup(tmp);
return gost_params[param];
}
@@ -85,8 +84,7 @@ int gost_set_default_param(int param, const char *value)
*/
if (!tmp)
tmp = value;
- if (gost_params[param])
- OPENSSL_free(gost_params[param]);
+ OPENSSL_free(gost_params[param]);
gost_params[param] = BUF_strdup(tmp);
return 1;
diff --git a/engines/ccgost/gost_pmeth.c b/engines/ccgost/gost_pmeth.c
index 673b538..416f0f9 100644
--- a/engines/ccgost/gost_pmeth.c
+++ b/engines/ccgost/gost_pmeth.c
@@ -66,8 +66,8 @@ static int pkey_gost_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
static void pkey_gost_cleanup(EVP_PKEY_CTX *ctx)
{
struct gost_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
- if (data->shared_ukm)
- OPENSSL_free(data->shared_ukm);
+
+ OPENSSL_free(data->shared_ukm);
OPENSSL_free(data);
}
diff --git a/engines/e_4758cca.c b/engines/e_4758cca.c
index b605a79..9c98129 100644
--- a/engines/e_4758cca.c
+++ b/engines/e_4758cca.c
@@ -474,8 +474,7 @@ static EVP_PKEY *ibm_4758_load_privkey(ENGINE *e, const char *key_id,
return res;
err:
- if (keyToken)
- OPENSSL_free(keyToken);
+ OPENSSL_free(keyToken);
return NULL;
}
@@ -544,8 +543,7 @@ static EVP_PKEY *ibm_4758_load_pubkey(ENGINE *e, const char *key_id,
return res;
err:
- if (keyToken)
- OPENSSL_free(keyToken);
+ OPENSSL_free(keyToken);
return NULL;
}
@@ -924,8 +922,7 @@ static int cca_get_random_bytes(unsigned char *buf, int num)
static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
long argl, void *argp)
{
- if (item)
- OPENSSL_free(item);
+ OPENSSL_free(item);
}
# endif
diff --git a/engines/e_aep.c b/engines/e_aep.c
index 93a4be7..c86b34a 100644
--- a/engines/e_aep.c
+++ b/engines/e_aep.c
@@ -403,8 +403,7 @@ static const char *get_AEP_LIBNAME(void)
static void free_AEP_LIBNAME(void)
{
- if (AEP_LIBNAME)
- OPENSSL_free((void *)AEP_LIBNAME);
+ OPENSSL_free(AEP_LIBNAME);
AEP_LIBNAME = NULL;
}
diff --git a/engines/e_atalla.c b/engines/e_atalla.c
index 6a324e6..e9a6134 100644
--- a/engines/e_atalla.c
+++ b/engines/e_atalla.c
@@ -324,8 +324,7 @@ static const char *get_ATALLA_LIBNAME(void)
static void free_ATALLA_LIBNAME(void)
{
- if (ATALLA_LIBNAME)
- OPENSSL_free((void *)ATALLA_LIBNAME);
+ OPENSSL_free(ATALLA_LIBNAME);
ATALLA_LIBNAME = NULL;
}
diff --git a/engines/e_capi.c b/engines/e_capi.c
index 2373d69..89e6d1d 100644
--- a/engines/e_capi.c
+++ b/engines/e_capi.c
@@ -360,8 +360,7 @@ static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
break;
case CAPI_CMD_STORE_NAME:
- if (ctx->storename)
- OPENSSL_free(ctx->storename);
+ OPENSSL_free(ctx->storename);
ctx->storename = BUF_strdup(p);
CAPI_trace(ctx, "Setting store name to %s\n", p);
break;
@@ -751,8 +750,7 @@ static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key)
}
err:
- if (pubkey)
- OPENSSL_free(pubkey);
+ OPENSSL_free(pubkey);
if (!ret) {
RSA_free(rkey);
DSA_free(dkey);
@@ -1232,8 +1230,7 @@ static int capi_list_containers(CAPI_CTX * ctx, BIO *out)
ret = 0;
done:
- if (cname)
- OPENSSL_free(cname);
+ OPENSSL_free(cname);
CryptReleaseContext(hprov, 0);
return ret;
@@ -1282,10 +1279,8 @@ static void capi_dump_prov_info(CAPI_CTX * ctx, BIO *out,
BIO_printf(out, " Container Name: %s, Key Type %d\n", contname,
pinfo->dwKeySpec);
err:
- if (provname)
- OPENSSL_free(provname);
- if (contname)
- OPENSSL_free(contname);
+ OPENSSL_free(provname);
+ OPENSSL_free(contname);
}
char *capi_cert_get_fname(CAPI_CTX * ctx, PCCERT_CONTEXT cert)
@@ -1346,8 +1341,7 @@ void capi_dump_cert(CAPI_CTX * ctx, BIO *out, PCCERT_CONTEXT cert)
CRYPT_KEY_PROV_INFO *pinfo;
pinfo = capi_get_prov_info(ctx, cert);
capi_dump_prov_info(ctx, out, pinfo);
- if (pinfo)
- OPENSSL_free(pinfo);
+ OPENSSL_free(pinfo);
}
if (flags & CAPI_DMP_PEM)
@@ -1462,10 +1456,8 @@ static CAPI_KEY *capi_get_key(CAPI_CTX * ctx, const TCHAR *contname,
CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n",
_contname, _provname, ptype);
- if (_provname)
- OPENSSL_free(_provname);
- if (_contname)
- OPENSSL_free(_contname);
+ OPENSSL_free(_provname);
+ OPENSSL_free(_contname);
}
if (ctx->store_flags & CERT_SYSTEM_STORE_LOCAL_MACHINE)
dwFlags = CRYPT_MACHINE_KEYSET;
@@ -1511,12 +1503,9 @@ static CAPI_KEY *capi_get_cert_key(CAPI_CTX * ctx, PCCERT_CONTEXT cert)
}
err:
- if (pinfo)
- OPENSSL_free(pinfo);
- if (provname)
- OPENSSL_free(provname);
- if (contname)
- OPENSSL_free(contname);
+ OPENSSL_free(pinfo);
+ OPENSSL_free(provname);
+ OPENSSL_free(contname);
return key;
}
@@ -1610,14 +1599,10 @@ static void capi_ctx_free(CAPI_CTX * ctx)
CAPI_trace(ctx, "Calling capi_ctx_free with %lx\n", ctx);
if (!ctx)
return;
- if (ctx->cspname)
- OPENSSL_free(ctx->cspname);
- if (ctx->debug_file)
- OPENSSL_free(ctx->debug_file);
- if (ctx->storename)
- OPENSSL_free(ctx->storename);
- if (ctx->ssl_client_store)
- OPENSSL_free(ctx->ssl_client_store);
+ OPENSSL_free(ctx->cspname);
+ OPENSSL_free(ctx->debug_file);
+ OPENSSL_free(ctx->storename);
+ OPENSSL_free(ctx->ssl_client_store);
OPENSSL_free(ctx);
}
@@ -1647,8 +1632,7 @@ static int capi_ctx_set_provname(CAPI_CTX * ctx, LPSTR pname, DWORD type,
}
CryptReleaseContext(hprov, 0);
}
- if (ctx->cspname)
- OPENSSL_free(ctx->cspname);
+ OPENSSL_free(ctx->cspname);
ctx->cspname = BUF_strdup(pname);
ctx->csptype = type;
return 1;
diff --git a/engines/e_chil.c b/engines/e_chil.c
index 68c9145..3535214 100644
--- a/engines/e_chil.c
+++ b/engines/e_chil.c
@@ -462,8 +462,7 @@ static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL;
static const char *HWCRHK_LIBNAME = NULL;
static void free_HWCRHK_LIBNAME(void)
{
- if (HWCRHK_LIBNAME)
- OPENSSL_free((void *)HWCRHK_LIBNAME);
+ OPENSSL_free(HWCRHK_LIBNAME);
HWCRHK_LIBNAME = NULL;
}
diff --git a/engines/e_cswift.c b/engines/e_cswift.c
index 848d10f..0b4bfc5 100644
--- a/engines/e_cswift.c
+++ b/engines/e_cswift.c
@@ -338,8 +338,7 @@ static const char *get_CSWIFT_LIBNAME(void)
static void free_CSWIFT_LIBNAME(void)
{
- if (CSWIFT_LIBNAME)
- OPENSSL_free((void *)CSWIFT_LIBNAME);
+ OPENSSL_free(CSWIFT_LIBNAME);
CSWIFT_LIBNAME = NULL;
}
@@ -707,16 +706,11 @@ static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
to_return = 1;
err:
- if (sw_param.up.crt.p.value)
- OPENSSL_free(sw_param.up.crt.p.value);
- if (sw_param.up.crt.q.value)
- OPENSSL_free(sw_param.up.crt.q.value);
- if (sw_param.up.crt.dmp1.value)
- OPENSSL_free(sw_param.up.crt.dmp1.value);
- if (sw_param.up.crt.dmq1.value)
- OPENSSL_free(sw_param.up.crt.dmq1.value);
- if (sw_param.up.crt.iqmp.value)
- OPENSSL_free(sw_param.up.crt.iqmp.value);
+ OPENSSL_free(sw_param.up.crt.p.value);
+ OPENSSL_free(sw_param.up.crt.q.value);
+ OPENSSL_free(sw_param.up.crt.dmp1.value);
+ OPENSSL_free(sw_param.up.crt.dmq1.value);
+ OPENSSL_free(sw_param.up.crt.iqmp.value);
BN_free(result);
BN_free(argument);
if (acquired)
diff --git a/engines/e_nuron.c b/engines/e_nuron.c
index 3437f36..01229b0 100644
--- a/engines/e_nuron.c
+++ b/engines/e_nuron.c
@@ -90,8 +90,7 @@ static const char *get_NURON_LIBNAME(void)
static void free_NURON_LIBNAME(void)
{
- if (NURON_LIBNAME)
- OPENSSL_free((void *)NURON_LIBNAME);
+ OPENSSL_free(NURON_LIBNAME);
NURON_LIBNAME = NULL;
}
diff --git a/engines/e_ubsec.c b/engines/e_ubsec.c
index 9e2662e..c7eb892 100644
--- a/engines/e_ubsec.c
+++ b/engines/e_ubsec.c
@@ -339,8 +339,7 @@ static const char *get_UBSEC_LIBNAME(void)
static void free_UBSEC_LIBNAME(void)
{
- if (UBSEC_LIBNAME)
- OPENSSL_free((void *)UBSEC_LIBNAME);
+ OPENSSL_free(UBSEC_LIBNAME);
UBSEC_LIBNAME = NULL;
}