mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
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:
1 parent
6a16368611
commit
ba6eb8af12
1 file changed
+5
-1
+5
-1
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user