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]); |
} |