Chromium Code Reviews| Index: src/factory.cc |
| diff --git a/src/factory.cc b/src/factory.cc |
| index a876f9f6fc3ae0ec933f4bdffc848903cab95b8d..24f3a0ada74d549b4e368fd8328bb63366cc41c1 100644 |
| --- a/src/factory.cc |
| +++ b/src/factory.cc |
| @@ -820,6 +820,7 @@ MaybeHandle<String> Factory::NewExternalStringFromOneByte( |
| if (length > static_cast<size_t>(String::kMaxLength)) { |
| THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), String); |
| } |
| + if (length == 0) return empty_string(); |
|
Jakob Kummerow
2017/02/08 01:41:57
Our public API would be fine with a DCHECK here, b
|
| Handle<Map> map; |
| if (resource->IsCompressible()) { |
| @@ -844,6 +845,7 @@ MaybeHandle<String> Factory::NewExternalStringFromTwoByte( |
| if (length > static_cast<size_t>(String::kMaxLength)) { |
| THROW_NEW_ERROR(isolate(), NewInvalidStringLengthError(), String); |
| } |
| + if (length == 0) return empty_string(); |
| // For small strings we check whether the resource contains only |
| // one byte characters. If yes, we use a different string map. |