aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/crypto.c
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2018-05-07 14:00:38 +0200
committerHans Nilsson <[email protected]>2018-06-04 12:06:58 +0200
commita9c7e47957c77b74f2b2261ad79a4f0f257dfbf7 (patch)
tree26ddf5b35880d205185a49743ea776ece40b3fc1 /lib/crypto/c_src/crypto.c
parent097c9d58ca8ced30fb7d7b9b373bd859aced40b8 (diff)
downloadotp-a9c7e47957c77b74f2b2261ad79a4f0f257dfbf7.tar.gz
otp-a9c7e47957c77b74f2b2261ad79a4f0f257dfbf7.tar.bz2
otp-a9c7e47957c77b74f2b2261ad79a4f0f257dfbf7.zip
crypto: Valgrind suggestions
Diffstat (limited to 'lib/crypto/c_src/crypto.c')
-rw-r--r--lib/crypto/c_src/crypto.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 6e113ef39e..2c69dbb5ff 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -3071,10 +3071,11 @@ static ERL_NIF_TERM dh_generate_key_nif(ErlNifEnv* env, int argc, const ERL_NIF_
if ((dhkey = EVP_PKEY_new())
&& (params = EVP_PKEY_new())
&& EVP_PKEY_set1_DH(params, dh_params) /* set the key referenced by params to dh_params.
- dh_params (and params) must be freed by us*/
+ dh_params (and params) must be freed */
&& (ctx = EVP_PKEY_CTX_new(params, NULL))
&& EVP_PKEY_keygen_init(ctx)
- && EVP_PKEY_keygen(ctx, &dhkey)
+ && EVP_PKEY_keygen(ctx, &dhkey) /* "performs a key generation operation, the
+ generated key is written to ppkey." (=last arg) */
&& (dh_params = EVP_PKEY_get1_DH(dhkey)) /* return the referenced key. dh_params and dhkey must be freed */
) {
#else
@@ -3108,8 +3109,8 @@ static ERL_NIF_TERM dh_generate_key_nif(ErlNifEnv* env, int argc, const ERL_NIF_
DH_free(dh_params);
#ifdef HAS_EVP_PKEY_CTX
if (ctx) EVP_PKEY_CTX_free(ctx);
- /* if (dhkey) EVP_PKEY_free(dhkey); */
- /* if (params) EVP_PKEY_free(params); */
+ if (dhkey) EVP_PKEY_free(dhkey);
+ if (params) EVP_PKEY_free(params);
#endif
return ret;
}
@@ -3207,7 +3208,7 @@ static ERL_NIF_TERM dh_compute_key_nif(ErlNifEnv* env, int argc, const ERL_NIF_T
if (dh_pub) DH_free(dh_pub);
#ifdef HAS_EVP_PKEY_CTX
if (ctx) EVP_PKEY_CTX_free(ctx);
- /* if (my_priv_key) EVP_PKEY_free(my_priv_key); */
+ if (my_priv_key) EVP_PKEY_free(my_priv_key);
/* if (peer_pub_key) EVP_PKEY_free(peer_pub_key); */
#endif
return ret;