| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 753b4716b0f6e5b778c7853ea823cbeaa581ffe9..7b5cca51196abeac5012ae59c0cbc71c24d634c0 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -21984,3 +21984,35 @@ TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
|
| RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
|
| "bar2.js");
|
| }
|
| +
|
| +
|
| +TEST(NewStringRangeError) {
|
| + v8::Isolate* isolate = CcTest::isolate();
|
| + v8::HandleScope handle_scope(isolate);
|
| + LocalContext env;
|
| + const int length = i::String::kMaxLength + 1;
|
| + const int buffer_size = length * sizeof(uint16_t);
|
| + void* buffer = malloc(buffer_size);
|
| + memset(buffer, 'A', buffer_size);
|
| + {
|
| + v8::TryCatch try_catch;
|
| + char* data = reinterpret_cast<char*>(buffer);
|
| + CHECK(v8::String::NewFromUtf8(isolate, data, v8::String::kNormalString,
|
| + length).IsEmpty());
|
| + CHECK(try_catch.HasCaught());
|
| + }
|
| + {
|
| + v8::TryCatch try_catch;
|
| + uint8_t* data = reinterpret_cast<uint8_t*>(buffer);
|
| + CHECK(v8::String::NewFromOneByte(isolate, data, v8::String::kNormalString,
|
| + length).IsEmpty());
|
| + CHECK(try_catch.HasCaught());
|
| + }
|
| + {
|
| + v8::TryCatch try_catch;
|
| + uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
|
| + CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
|
| + length).IsEmpty());
|
| + CHECK(try_catch.HasCaught());
|
| + }
|
| +}
|
|
|