aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/crypto.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-06-04 15:46:53 +0200
committerSverker Eriksson <[email protected]>2014-06-04 15:46:53 +0200
commitc9e36ab16034bb7fe71f772df6bba22070976bbf (patch)
treec04bea8aab5b5343b04ab07daab0a6e533ad952c /lib/crypto/c_src/crypto.c
parentf29a78c97709ad94a4255fb5b2566b3a1b3af933 (diff)
parentfb6d7a6e6eacc7767fd5faf262eda6791de44fe7 (diff)
downloadotp-c9e36ab16034bb7fe71f772df6bba22070976bbf.tar.gz
otp-c9e36ab16034bb7fe71f772df6bba22070976bbf.tar.bz2
otp-c9e36ab16034bb7fe71f772df6bba22070976bbf.zip
Merge branch 'sverk/crypto-leaking-hmac/OTP-11953' into maint
* sverk/crypto-leaking-hmac/OTP-11953: crypto: Fix memory leak in some error cases crypto: Fix memory leak in hmac stream functions
Diffstat (limited to 'lib/crypto/c_src/crypto.c')
-rw-r--r--lib/crypto/c_src/crypto.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 3020cadc56..948093d69c 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[])
@@ -2506,6 +2509,7 @@ static ERL_NIF_TERM dss_sign_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar
return enif_make_binary(env, &ret_bin);
}
else {
+ enif_release_binary(&ret_bin);
return atom_error;
}
}
@@ -2768,6 +2772,7 @@ static ERL_NIF_TERM dh_compute_key_nif(ErlNifEnv* env, int argc, const ERL_NIF_T
ret = enif_make_binary(env, &ret_bin);
}
else {
+ enif_release_binary(&ret_bin);
ret = atom_error;
}
}