Index: src/runtime/runtime-i18n.cc |
diff --git a/src/runtime/runtime-i18n.cc b/src/runtime/runtime-i18n.cc |
index 75e0952581b3723aea67e4e9b108534d926fec86..9f7b24b6318f841a41adbf8a78670fc6dda04b2a 100644 |
--- a/src/runtime/runtime-i18n.cc |
+++ b/src/runtime/runtime-i18n.cc |
@@ -948,6 +948,8 @@ MUST_USE_RESULT Object* LocaleConvertCase(Handle<String> s, Isolate* isolate, |
Handle<SeqTwoByteString> result; |
std::unique_ptr<uc16[]> sap; |
+ if (dest_length == 0) return isolate->heap()->empty_string(); |
+ |
// This is not a real loop. It'll be executed only once (no overflow) or |
// twice (overflow). |
for (int i = 0; i < 2; ++i) { |
@@ -1159,7 +1161,7 @@ RUNTIME_FUNCTION(Runtime_StringToUpperCaseI18N) { |
int32_t length = s->length(); |
s = String::Flatten(s); |
- if (s->HasOnlyOneByteChars()) { |
+ if (s->HasOnlyOneByteChars() && length > 0) { |
Handle<SeqOneByteString> result; |
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
isolate, result, isolate->factory()->NewRawOneByteString(length)); |