Skip to content

Commit 377e8ce

Browse files
codebytereaduh95
authored andcommitted
tls: avoid external memory leak on invalid protocol versions
PR-URL: #60390 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ethan Arrowood <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 4a5d7a4 commit 377e8ce

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/internal/tls/common.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ function SecureContext(secureProtocol, secureOptions, minVersion, maxVersion) {
8282
throw new ERR_TLS_PROTOCOL_VERSION_CONFLICT(maxVersion, secureProtocol);
8383
}
8484

85+
const minV = toV('minimum', minVersion, tls.DEFAULT_MIN_VERSION);
86+
const maxV = toV('maximum', maxVersion, tls.DEFAULT_MAX_VERSION);
87+
8588
this.context = new NativeSecureContext();
86-
this.context.init(secureProtocol,
87-
toV('minimum', minVersion, tls.DEFAULT_MIN_VERSION),
88-
toV('maximum', maxVersion, tls.DEFAULT_MAX_VERSION));
89+
this.context.init(secureProtocol, minV, maxV);
8990

9091
if (secureOptions) {
9192
validateInteger(secureOptions, 'secureOptions');

0 commit comments

Comments
 (0)