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

Unified Diff: runtime/bin/platform.cc

Issue 2273053002: Ignore non-UTF8 strings in the environment (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | sdk/lib/io/platform_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | sdk/lib/io/platform_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698