OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 23363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23374 // TestSourceStream::GetMoreData won't block, so it's OK to just run the | 23374 // TestSourceStream::GetMoreData won't block, so it's OK to just run the |
23375 // task here in the main thread. | 23375 // task here in the main thread. |
23376 task->Run(); | 23376 task->Run(); |
23377 delete task; | 23377 delete task; |
23378 | 23378 |
23379 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); | 23379 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); |
23380 CHECK(cached_data != NULL); | 23380 CHECK(cached_data != NULL); |
23381 CHECK(cached_data->data != NULL); | 23381 CHECK(cached_data->data != NULL); |
23382 CHECK_GT(cached_data->length, 0); | 23382 CHECK_GT(cached_data->length, 0); |
23383 } | 23383 } |
| 23384 |
| 23385 |
| 23386 TEST(StreamingScriptWithInvalidUtf8) { |
| 23387 // Regression test for a crash: test that invalid UTF-8 bytes in the end of a |
| 23388 // chunk don't produce a crash. |
| 23389 const char* reference = "\xeb\x91\x80\x80\x80"; |
| 23390 char chunk1[] = |
| 23391 "function foo() {\n" |
| 23392 " // This function will contain an UTF-8 character which is not in\n" |
| 23393 " // ASCII.\n" |
| 23394 " var foobXXXXX"; // Too many bytes which look like incomplete chars! |
| 23395 char chunk2[] = |
| 23396 "r = 13;\n" |
| 23397 " return foob\xeb\x91\x80\x80\x80r;\n" |
| 23398 "}\n"; |
| 23399 for (int i = 0; i < 5; ++i) chunk1[strlen(chunk1) - 5 + i] = reference[i]; |
| 23400 |
| 23401 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; |
| 23402 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, false); |
| 23403 } |
OLD | NEW |