crypto: fix memory leak in SetDHParam

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 Ben Noordhuis committed 2015-08-17 21:23:07 +02:00
1 parent b48385a3aa
commit 98d7aee602
1 file changed
+4 -2
+4 -2
View File
@@ -805,10 +805,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
return;
const int keylen = BN_num_bits(dh->p);
if (keylen < 1024)
if (keylen < 1024) {
DH_free(dh);
return env->ThrowError("DH parameter is less than 1024 bits");
else if (keylen < 2048)
} else if (keylen < 2048) {
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
}
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);
int r = SSL_CTX_set_tmp_dh(sc->ctx_, dh);