Index: runtime/bin/platform.cc |
diff --git a/runtime/bin/platform.cc b/runtime/bin/platform.cc |
index 3dccea7083a78e73a6f79312a818cec62f4e5be0..d09a8be512bbab43755f4dcff9e4ccfffefffa02 100644 |
--- a/runtime/bin/platform.cc |
+++ b/runtime/bin/platform.cc |
@@ -103,15 +103,19 @@ void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) { |
if (Dart_IsError(result)) { |
Dart_PropagateError(result); |
} |
- for (intptr_t i = 0; i < count; i++) { |
- Dart_Handle str = DartUtils::NewString(env[i]); |
+ intptr_t result_idx = 0; |
+ for (intptr_t env_idx = 0; env_idx < count; env_idx++) { |
+ Dart_Handle str = DartUtils::NewString(env[env_idx]); |
if (Dart_IsError(str)) { |
- Dart_PropagateError(str); |
+ // Silently skip over environment entries that are not valid UTF8 |
+ // strings. |
+ continue; |
} |
- Dart_Handle error = Dart_ListSetAt(result, i, str); |
+ Dart_Handle error = Dart_ListSetAt(result, result_idx, str); |
if (Dart_IsError(error)) { |
Dart_PropagateError(error); |
} |
+ result_idx++; |
} |
Dart_SetReturnValue(args, result); |
} |