aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-04-05 15:37:48 +0200
committerHans Nilsson <[email protected]>2019-04-10 10:25:21 +0200
commit4cdf1947c5b31e931c85ba6ac6ec6f2a7f12ef86 (patch)
treee963a55ecc9ba6588852a0f42c6f9f5eab8b12dc
parent29b2edbe96bccabd7ee25c2722246010e4a77871 (diff)
downloadotp-4cdf1947c5b31e931c85ba6ac6ec6f2a7f12ef86.tar.gz
otp-4cdf1947c5b31e931c85ba6ac6ec6f2a7f12ef86.tar.bz2
otp-4cdf1947c5b31e931c85ba6ac6ec6f2a7f12ef86.zip
crypto: Fix valgrind error in api_ng.c ng_crypto_one_time for OpenSSL<1.0.1
-rw-r--r--lib/crypto/c_src/api_ng.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/crypto/c_src/api_ng.c b/lib/crypto/c_src/api_ng.c
index 107723d2cb..3408ba1b88 100644
--- a/lib/crypto/c_src/api_ng.c
+++ b/lib/crypto/c_src/api_ng.c
@@ -522,6 +522,11 @@ ERL_NIF_TERM ng_crypto_one_time(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg
const struct cipher_type_t *cipherp;
ERL_NIF_TERM ret;
+ ctx_res.ctx = NULL;
+#if !defined(HAVE_EVP_AES_CTR)
+ ctx_res.env = NULL;
+#endif
+
if (!get_init_args(env, &ctx_res, argv[0], argv[1], argv[2], argv[4], &cipherp, &ret))
goto ret;
@@ -530,9 +535,16 @@ ERL_NIF_TERM ng_crypto_one_time(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg
ret:
if (ctx_res.ctx)
EVP_CIPHER_CTX_free(ctx_res.ctx);
+
+#if !defined(HAVE_EVP_AES_CTR)
+ if (ctx_res.env)
+ enif_free_env(ctx_res.env);
+#endif
+
return ret;
}
+
ERL_NIF_TERM ng_crypto_one_time_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{/* (Cipher, Key, IVec, Data, Encrypt) % if no IV for the Cipher, set IVec = <<>>
*/