Skip to content

Commit f45487c

Browse files
skomskiFishrock123
authored andcommitted
crypto: fix memory leak in SetDHParam
PR-URL: #2375 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent b196c1d commit f45487c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node_crypto.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
805805
return;
806806

807807
const int keylen = BN_num_bits(dh->p);
808-
if (keylen < 1024)
808+
if (keylen < 1024) {
809+
DH_free(dh);
809810
return env->ThrowError("DH parameter is less than 1024 bits");
810-
else if (keylen < 2048)
811+
} else if (keylen < 2048) {
811812
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
813+
}
812814

813815
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);
814816
int r = SSL_CTX_set_tmp_dh(sc->ctx_, dh);

0 commit comments

Comments
 (0)