node: fix argument parsing with -p arg
authorAlexis Campailla <alexis@janeasystems.com>
Sat, 28 Dec 2013 08:12:40 +0000 (15:12 +0700)
committerTimothy J Fontaine <tjfontaine@gmail.com>
Mon, 27 Jan 2014 19:54:53 +0000 (11:54 -0800)
node -p would cause an access violation.

Fixes test\message\stdin_messages.js on Windows.

src/node.cc

index 47ef87b..0b3697d 100644 (file)
@@ -2867,7 +2867,9 @@ static void ParseArgs(int* argc,
           fprintf(stderr, "%s: %s requires an argument\n", argv[0], arg);
           exit(9);
         }
-      } else if (argv[index + 1] != NULL && argv[index + 1][0] != '-') {
+      } else if ((index + 1 < nargs) &&
+                 argv[index + 1] != NULL &&
+                 argv[index + 1][0] != '-') {
         args_consumed += 1;
         eval_string = argv[index + 1];
         if (strncmp(eval_string, "\\-", 2) == 0) {