diff options
Diffstat (limited to 'deps/v8/src/unicode.cc')
-rw-r--r-- | deps/v8/src/unicode.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/deps/v8/src/unicode.cc b/deps/v8/src/unicode.cc index a128a6ff0..5f668c2ac 100644 --- a/deps/v8/src/unicode.cc +++ b/deps/v8/src/unicode.cc @@ -265,6 +265,7 @@ void Utf8DecoderBase::Reset(uint16_t* buffer, // Assume everything will fit in the buffer and stream won't be needed. last_byte_of_buffer_unused_ = false; unbuffered_start_ = NULL; + unbuffered_length_ = 0; bool writing_to_buffer = true; // Loop until stream is read, writing to buffer as long as buffer has space. unsigned utf16_length = 0; @@ -291,6 +292,7 @@ void Utf8DecoderBase::Reset(uint16_t* buffer, // Just wrote last character of buffer writing_to_buffer = false; unbuffered_start_ = stream; + unbuffered_length_ = stream_length; } continue; } @@ -300,20 +302,24 @@ void Utf8DecoderBase::Reset(uint16_t* buffer, writing_to_buffer = false; last_byte_of_buffer_unused_ = true; unbuffered_start_ = stream - cursor; + unbuffered_length_ = stream_length + cursor; } utf16_length_ = utf16_length; } void Utf8DecoderBase::WriteUtf16Slow(const uint8_t* stream, + unsigned stream_length, uint16_t* data, unsigned data_length) { while (data_length != 0) { unsigned cursor = 0; - uint32_t character = Utf8::ValueOf(stream, Utf8::kMaxEncodedSize, &cursor); + + uint32_t character = Utf8::ValueOf(stream, stream_length, &cursor); // There's a total lack of bounds checking for stream // as it was already done in Reset. stream += cursor; + stream_length -= cursor; if (character > unibrow::Utf16::kMaxNonSurrogateCharCode) { *data++ = Utf16::LeadSurrogate(character); *data++ = Utf16::TrailSurrogate(character); @@ -324,6 +330,7 @@ void Utf8DecoderBase::WriteUtf16Slow(const uint8_t* stream, data_length -= 1; } } + DCHECK(stream_length >= 0); } |