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

Unified Diff: mojo/apps/js/test/js_to_cpp_unittest.cc

Issue 284243002: Fix js_to_cpp_unittest handling of null arrays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: Created 6 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/apps/js/test/js_to_cpp_unittest.cc
diff --git a/mojo/apps/js/test/js_to_cpp_unittest.cc b/mojo/apps/js/test/js_to_cpp_unittest.cc
index d9e4cbdccf473237c5a9449ebcdef40cdc9e3a05..527c81b0966da08ad6fdc4d78995b326cb54632f 100644
--- a/mojo/apps/js/test/js_to_cpp_unittest.cc
+++ b/mojo/apps/js/test/js_to_cpp_unittest.cc
@@ -127,12 +127,15 @@ void CheckDataPipe(MojoHandle data_pipe_handle) {
void CheckCorruptedString(const mojo::String& arg) {
// The values don't matter so long as all accesses are within bounds.
- std::string name = arg.To<std::string>();
- for (size_t i = 0; i < name.length(); ++i)
- g_waste_accumulator += name[i];
+ if (arg.is_null())
+ return;
+ for (size_t i = 0; i < arg.size(); ++i)
+ g_waste_accumulator += arg[i];
}
void CheckCorruptedStringArray(const mojo::Array<mojo::String>& string_array) {
+ if (string_array.is_null())
+ return;
for (size_t i = 0; i < string_array.size(); ++i)
CheckCorruptedString(string_array[i]);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698