Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 089a1cb

Browse filesBrowse files
mscdexevanlucas
authored andcommitted
net: add length check when normalizing args
This helps to prevent possible deoptimizations that arise when trying to access nonexistent indices. PR-URL: #8112 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 17b8381 commit 089a1cb
Copy full SHA for 089a1cb

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ exports.connect = exports.createConnection = function() {
7474
function normalizeConnectArgs(args) {
7575
var options = {};
7676

77-
if (args[0] !== null && typeof args[0] === 'object') {
77+
if (args.length === 0) {
78+
return [options];
79+
} else if (args[0] !== null && typeof args[0] === 'object') {
7880
// connect(options, [cb])
7981
options = args[0];
8082
} else if (isPipeName(args[0])) {
@@ -83,7 +85,7 @@ function normalizeConnectArgs(args) {
8385
} else {
8486
// connect(port, [host], [cb])
8587
options.port = args[0];
86-
if (typeof args[1] === 'string') {
88+
if (args.length > 1 && typeof args[1] === 'string') {
8789
options.host = args[1];
8890
}
8991
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.