aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/engine
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 /crypto/engine
parent33fbca83dcd05b77f807fab205c4523b8cfe85b5 (diff)
downloadopenssl-b548a1f11c06ccdfa4f52a539912d22d77ee309e.tar.gz
free null cleanup finale
Don't check for NULL before calling OPENSSL_free Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/engine')
-rw-r--r--crypto/engine/eng_cryptodev.c8
-rw-r--r--crypto/engine/eng_dyn.c19
2 files changed, 10 insertions, 17 deletions
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index a3be0d79ed..d801ae8f1c 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -889,11 +889,9 @@ static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
return (0);
}
- if (state->mac_data) {
- OPENSSL_free(state->mac_data);
- state->mac_data = NULL;
- state->mac_len = 0;
- }
+ OPENSSL_free(state->mac_data);
+ state->mac_data = NULL;
+ state->mac_len = 0;
if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
printf("cryptodev_digest_cleanup: failed to close session\n");
diff --git a/crypto/engine/eng_dyn.c b/crypto/engine/eng_dyn.c
index 31ec324422..7dd3659e76 100644
--- a/crypto/engine/eng_dyn.c
+++ b/crypto/engine/eng_dyn.c
@@ -136,11 +136,11 @@ struct st_dynamic_data_ctx {
*/
dynamic_bind_engine bind_engine;
/* The default name/path for loading the shared library */
- const char *DYNAMIC_LIBNAME;
+ char *DYNAMIC_LIBNAME;
/* Whether to continue loading on a version check failure */
int no_vcheck;
/* If non-NULL, stipulates the 'id' of the ENGINE to be loaded */
- const char *engine_id;
+ char *engine_id;
/*
* If non-zero, a successfully loaded ENGINE should be added to the
* internal ENGINE list. If 2, the add must succeed or the entire load
@@ -188,10 +188,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)
- OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
- if (ctx->engine_id)
- OPENSSL_free((void *)ctx->engine_id);
+ OPENSSL_free(ctx->DYNAMIC_LIBNAME);
+ OPENSSL_free(ctx->engine_id);
if (ctx->dirs)
sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str);
OPENSSL_free(ctx);
@@ -243,8 +241,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
* If we lost the race to set the context, c is non-NULL and *ctx is the
* context of the thread that won.
*/
- if (c)
- OPENSSL_free(c);
+ OPENSSL_free(c);
return 1;
}
@@ -363,8 +360,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)
- OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
+ OPENSSL_free(ctx->DYNAMIC_LIBNAME);
if (p)
ctx->DYNAMIC_LIBNAME = BUF_strdup(p);
else
@@ -377,8 +373,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)
- OPENSSL_free((void *)ctx->engine_id);
+ OPENSSL_free(ctx->engine_id);
if (p)
ctx->engine_id = BUF_strdup(p);
else