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 Jeremiah Senkpiel committed 2015-08-19 11:39:27 -04:00
1 parent b196c1da3c
commit f45487cd6e
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);