Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index b4cf5cf4a9891e7442ac307a71b34bc761ac5927..66dc5a0c4ab0c8bb95f51eac826f971a448b3c66 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -23381,3 +23381,23 @@ TEST(StreamingProducesParserCache) { |
CHECK(cached_data->data != NULL); |
CHECK_GT(cached_data->length, 0); |
} |
+ |
+ |
+TEST(StreamingScriptWithInvalidUtf8) { |
+ // Regression test for a crash: test that invalid UTF-8 bytes in the end of a |
+ // chunk don't produce a crash. |
+ const char* reference = "\xeb\x91\x80\x80\x80"; |
+ char chunk1[] = |
+ "function foo() {\n" |
+ " // This function will contain an UTF-8 character which is not in\n" |
+ " // ASCII.\n" |
+ " var foobXXXXX"; // Too many bytes which look like incomplete chars! |
+ char chunk2[] = |
+ "r = 13;\n" |
+ " return foob\xeb\x91\x80\x80\x80r;\n" |
+ "}\n"; |
+ for (int i = 0; i < 5; ++i) chunk1[strlen(chunk1) - 5 + i] = reference[i]; |
+ |
+ const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; |
+ RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, false); |
+} |