| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index 2c8009e1d3cd80ccadb86940476edb47a4e148be..239c7ac21892a5e0b1ae43aa9cf82e4bba9ba48b 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -5545,7 +5545,11 @@ Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
|
| LOG_API(isolate, "String::New(char)");
|
| ENTER_V8(isolate);
|
| i::Handle<i::String> right_string = Utils::OpenHandle(*right);
|
| - // We do not expect this to fail. Change this if it does.
|
| + // If we are steering towards a range error, do not wait for the error to be
|
| + // thrown, and return the null handle instead.
|
| + if (left_string->length() + right_string->length() > i::String::kMaxLength) {
|
| + return Local<String>();
|
| + }
|
| i::Handle<i::String> result = isolate->factory()->NewConsString(
|
| left_string, right_string).ToHandleChecked();
|
| return Utils::ToLocal(result);
|
|
|