tls: avoid external memory leak on invalid protocol versions

PR-URL: https://github.com/nodejs/node/pull/60390
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Shelley Vohr
2025-10-26 17:29:49 +01:00
committed by GitHub
parent a7d9c49490
commit fb84f35fec

View File

@@ -82,10 +82,11 @@ function SecureContext(secureProtocol, secureOptions, minVersion, maxVersion) {
throw new ERR_TLS_PROTOCOL_VERSION_CONFLICT(maxVersion, secureProtocol);
}
const minV = toV('minimum', minVersion, tls.DEFAULT_MIN_VERSION);
const maxV = toV('maximum', maxVersion, tls.DEFAULT_MAX_VERSION);
this.context = new NativeSecureContext();
this.context.init(secureProtocol,
toV('minimum', minVersion, tls.DEFAULT_MIN_VERSION),
toV('maximum', maxVersion, tls.DEFAULT_MAX_VERSION));
this.context.init(secureProtocol, minV, maxV);
if (secureOptions) {
validateInteger(secureOptions, 'secureOptions');