Skip to content

Commit

Permalink
crypto: fix memory leak in ECDH::SetPrivateKey
Browse files Browse the repository at this point in the history
PR-URL: #2375
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
skomski authored and Fishrock123 committed Aug 19, 2015
1 parent 6a16368 commit ba6eb8a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}


Expand Down

0 comments on commit ba6eb8a

Please sign in to comment.