Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: runtime/bin/main.cc

Issue 2409263004: Fix for issue 27567 (inconsistent handling of invalid -D options (Closed)
Patch Set: Address code review comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/env_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index fe0c8ede3b826895696d248ec1a1c52e2327ef20..b5ef0870b9f687c4d8c31bef1b7420cd8393fb85 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -276,32 +276,32 @@ static bool ProcessEnvironmentOption(const char* arg,
ASSERT(arg != NULL);
if (*arg == '\0') {
// Ignore empty -D option.
- Log::PrintErr("No arguments given to -D option\n");
+ Log::PrintErr("No arguments given to -D option, ignoring it\n");
return true;
}
- if (environment == NULL) {
- environment = new HashMap(&HashMap::SameStringValue, 4);
- }
// Split the name=value part of the -Dname=value argument.
const char* equals_pos = strchr(arg, '=');
if (equals_pos == NULL) {
// No equal sign (name without value) currently not supported.
- Log::PrintErr("No value given to -D option\n");
- return false;
+ Log::PrintErr("No value given in -D%s option, ignoring it\n", arg);
+ return true;
}
char* name;
char* value = NULL;
int name_len = equals_pos - arg;
if (name_len == 0) {
- Log::PrintErr("No name given to -D option\n");
- return false;
+ Log::PrintErr("No name given in -D%s option, ignoring it\n", arg);
+ return true;
}
// Split name=value into name and value.
name = reinterpret_cast<char*>(malloc(name_len + 1));
strncpy(name, arg, name_len);
name[name_len] = '\0';
value = strdup(equals_pos + 1);
+ if (environment == NULL) {
+ environment = new HashMap(&HashMap::SameStringValue, 4);
+ }
HashMap::Entry* entry = environment->Lookup(
GetHashmapKeyFromString(name), HashMap::StringHash(name), true);
ASSERT(entry != NULL); // Lookup adds an entry if key not found.
« no previous file with comments | « no previous file | tests/standalone/env_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698