Reviewers: Hannes Payer,

Description:
Fix command line parsing.

For --min-parse-length --cache=code, SetFlagsFromCommandLine sees an
argv like this: [".../blabla/d8", "min-parse-length", NULL] It then
calls strtol(NULL, ...), which strtol dislikes.

It turns out that:
- V8::Shell::SetOptions will pick out its own arguments, and replace
  them in argv with NULL values.
- v8::internal::SetFlagsFromCommandLine is mostly aware of this.
- However, when a general v8 argument w/ parameter is followed by
  a d8 argument then this happens:
  - SetOptions parses its arguments and replaces it will NULL.
  - SetFlagsFromCommandLine tries to parse and arg w/ parameter,
    but finds a NULL in its place.
  - The parsing function for the argument receives a NULL pointer
    and doesn't like it.

Easy to fix by checking for NULL after argv.
Probably little real world effect, since this only affects v8 when
used through d8.


[email protected]
BUG=401432

Please review this at https://codereview.chromium.org/452093002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+2, -1 lines):
  M src/flags.cc


Index: src/flags.cc
diff --git a/src/flags.cc b/src/flags.cc
index 8ddd836817286a3eb9830ead0791e9f35a7d7c9d..98f21ef2c4c9e9ba4c7cf1adcec58593ef234709 100644
--- a/src/flags.cc
+++ b/src/flags.cc
@@ -372,7 +372,8 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
           value == NULL) {
         if (i < *argc) {
           value = argv[i++];
-        } else {
+        }
+        if (!value) {
           PrintF(stderr, "Error: missing value for flag %s of type %s\n"
                  "Try --help for options\n",
                  arg, Type2String(flag->type()));


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to