aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-06-18 16:40:55 +0200
committerSverker Eriksson <[email protected]>2014-06-18 16:40:55 +0200
commit3e04f2d1e62aa76f0ffe4ad36dccd843cc89b9ae (patch)
tree55c854bae6a6069f770bf4d2f1fbe2cb667d7a27 /lib/crypto/c_src
parent70c6e5a1baa326c9809851e00b8849cb6706f812 (diff)
downloadotp-3e04f2d1e62aa76f0ffe4ad36dccd843cc89b9ae.tar.gz
otp-3e04f2d1e62aa76f0ffe4ad36dccd843cc89b9ae.tar.bz2
otp-3e04f2d1e62aa76f0ffe4ad36dccd843cc89b9ae.zip
crypto: Fix memory leak of EC "keys" and "points"
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r--lib/crypto/c_src/crypto.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 828f9a8a2b..83c53f8b9f 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -3222,6 +3222,7 @@ out:
if (bn_order) BN_free(bn_order);
if (cofactor) BN_free(cofactor);
if (group) EC_GROUP_free(group);
+ if (point) EC_POINT_free(point);
return key;
}
@@ -3384,8 +3385,11 @@ static ERL_NIF_TERM ec_key_generate(ErlNifEnv* env, int argc, const ERL_NIF_TERM
EC_KEY_free(key);
return enif_make_tuple2(env, pub_key, priv_key);
}
- else
+ else {
+ if (key)
+ EC_KEY_free(key);
return enif_make_badarg(env);
+ }
#else
return atom_notsup;
#endif