aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-05-26 16:18:41 +0200
committerSverker Eriksson <[email protected]>2014-05-26 16:18:41 +0200
commitd282da3510b56313feb7c52e7844880f4d87d088 (patch)
tree05f75af38ad26dc6ad8446068adc7c44116b0cba /lib/crypto/c_src
parent6731d295915448e4c219f1db1b146264ced68018 (diff)
downloadotp-d282da3510b56313feb7c52e7844880f4d87d088.tar.gz
otp-d282da3510b56313feb7c52e7844880f4d87d088.tar.bz2
otp-d282da3510b56313feb7c52e7844880f4d87d088.zip
crypto: Fix memory leak in hmac stream functions
The context was never deallocated.
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r--lib/crypto/c_src/crypto.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 3020cadc56..e7fd0c82ec 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -1384,6 +1384,7 @@ static ERL_NIF_TERM hmac_init(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[
ErlNifBinary key;
struct hmac_context* obj;
const EVP_MD *md;
+ ERL_NIF_TERM ret;
CHECK_OSE_CRYPTO();
@@ -1415,7 +1416,9 @@ static ERL_NIF_TERM hmac_init(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[
HMAC_CTX_init(&obj->ctx);
HMAC_Init(&obj->ctx, key.data, key.size, md);
- return enif_make_resource(env, obj);
+ ret = enif_make_resource(env, obj);
+ enif_release_resource(obj);
+ return ret;
}
static ERL_NIF_TERM hmac_update(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])