Skip to content

Commit 14d6df8

Browse files
orangemochatjfontaine
authored andcommitted
node: fix argument parsing with -p arg
node -p would cause an access violation. Fixes test\message\stdin_messages.js on Windows.
1 parent c37e1b7 commit 14d6df8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,9 @@ static void ParseArgs(int* argc,
28672867
fprintf(stderr, "%s: %s requires an argument\n", argv[0], arg);
28682868
exit(9);
28692869
}
2870-
} else if (argv[index + 1] != NULL && argv[index + 1][0] != '-') {
2870+
} else if ((index + 1 < nargs) &&
2871+
argv[index + 1] != NULL &&
2872+
argv[index + 1][0] != '-') {
28712873
args_consumed += 1;
28722874
eval_string = argv[index + 1];
28732875
if (strncmp(eval_string, "\\-", 2) == 0) {

0 commit comments

Comments
 (0)