crypto: fix memory leak in ECDH::SetPrivateKey

PR-URL: https://github.com/nodejs/node/pull/2375
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Karl Skomski authored and Jeremiah Senkpiel committed 2015-08-19 11:39:27 -04:00
1 parent 6a16368611
commit ba6eb8af12
1 file changed
+5 -1
+5 -1
View File
@@ -4568,8 +4568,12 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
if (priv == nullptr)
return env->ThrowError("Failed to convert Buffer to BN");
if (!EC_KEY_set_private_key(ecdh->key_, priv))
int result = EC_KEY_set_private_key(ecdh->key_, priv);
BN_free(priv);
if (!result) {
return env->ThrowError("Failed to convert BN to a private key");
}
}