| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index f88ebda53d117dfd5b283b513f7743824f1d408c..8a92c5b07633ab3ea16421ed4ad6065ac262b9cc 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -3348,9 +3348,12 @@ MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string,
|
|
|
| // Copy the characters into the new object.
|
| SeqAsciiString* string_result = SeqAsciiString::cast(result);
|
| - for (int i = 0; i < string.length(); i++) {
|
| + int i;
|
| + for (i = 0; i < string.length(); i++) {
|
| string_result->SeqAsciiStringSet(i, string[i]);
|
| + if (string[i] == '\0') break;
|
| }
|
| + string_result->set_length(i);
|
| return result;
|
| }
|
|
|
| @@ -3378,11 +3381,14 @@ MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string,
|
| // Convert and copy the characters into the new object.
|
| String* string_result = String::cast(result);
|
| decoder->Reset(string.start(), string.length());
|
| - for (int i = 0; i < chars; i++) {
|
| + int i;
|
| + for (i = 0; i < chars; i++) {
|
| uc32 r = decoder->GetNext();
|
| if (r > kMaxSupportedChar) { r = unibrow::Utf8::kBadChar; }
|
| string_result->Set(i, r);
|
| + if (r == 0) break;
|
| }
|
| + string_result->set_length(i);
|
| return result;
|
| }
|
|
|
|
|