diff options
author | Andrea Grandi <andrea.grandi@intel.com> | 2016-02-27 06:14:49 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-03-07 16:27:25 +0000 |
commit | b283968327219aa6e4f57596f1234a32ea7df484 (patch) | |
tree | 7908b7d04c7ebfaf382663f3509a72f8885a2002 /apps/speed.c | |
parent | 0ff4343575882fe767da1c62e1f9586d8f29e73c (diff) | |
download | openssl-b283968327219aa6e4f57596f1234a32ea7df484.tar.gz |
Remove unnecessary memset() to 0 and check for NULL before OPENSSL_free()
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'apps/speed.c')
-rw-r--r-- | apps/speed.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/apps/speed.c b/apps/speed.c index 5765aa0c27..32b4d05e70 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -1580,19 +1580,7 @@ int speed_main(int argc, char **argv) loopargs[i].buf = loopargs[i].buf_malloc + misalign; loopargs[i].buf2 = loopargs[i].buf2_malloc + misalign; loopargs[i].siglen = app_malloc(sizeof(unsigned int), "signature length"); -#ifndef OPENSSL_NO_DSA - memset(loopargs[i].dsa_key, 0, sizeof(loopargs[i].dsa_key)); -#endif -#ifndef OPENSSL_NO_RSA - memset(loopargs[i].rsa_key, 0, sizeof(loopargs[i].rsa_key)); - for (k = 0; k < RSA_NUM; k++) - loopargs[i].rsa_key[k] = NULL; -#endif #ifndef OPENSSL_NO_EC - for (k = 0; k < EC_NUM; k++) - loopargs[i].ecdsa[k] = NULL; - for (k = 0; k < EC_NUM; k++) - loopargs[i].ecdh_a[k] = loopargs[i].ecdh_b[k] = NULL; loopargs[i].secret_a = app_malloc(MAX_ECDH_SIZE, "ECDH secret a"); loopargs[i].secret_b = app_malloc(MAX_ECDH_SIZE, "ECDH secret b"); #endif @@ -2828,15 +2816,11 @@ int speed_main(int argc, char **argv) end: ERR_print_errors(bio_err); for (i = 0; i < loopargs_len; i++) { - if (loopargs[i].buf_malloc != NULL) - OPENSSL_free(loopargs[i].buf_malloc); - if (loopargs[i].buf2_malloc != NULL) - OPENSSL_free(loopargs[i].buf2_malloc); - if (loopargs[i].siglen != NULL) - OPENSSL_free(loopargs[i].siglen); - } - if (loopargs != NULL) - OPENSSL_free(loopargs); + OPENSSL_free(loopargs[i].buf_malloc); + OPENSSL_free(loopargs[i].buf2_malloc); + OPENSSL_free(loopargs[i].siglen); + } + OPENSSL_free(loopargs); #ifndef OPENSSL_NO_RSA for (i = 0; i < loopargs_len; i++) { for (k = 0; k < RSA_NUM; k++) @@ -2857,10 +2841,8 @@ int speed_main(int argc, char **argv) EC_KEY_free(loopargs[i].ecdh_a[k]); EC_KEY_free(loopargs[i].ecdh_b[k]); } - if (loopargs[i].secret_a) - OPENSSL_free(loopargs[i].secret_a); - if (loopargs[i].secret_b) - OPENSSL_free(loopargs[i].secret_b); + OPENSSL_free(loopargs[i].secret_a); + OPENSSL_free(loopargs[i].secret_b); } #endif if (async_jobs > 0) |