Chromium Code Reviews| Index: runtime/vm/json_stream.cc |
| diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc |
| index f1a0d875d1e60ab9a0164ea12794ab2d3f1a9dd1..08f08edf6c2515cc9587de081fcf2a004109df6f 100644 |
| --- a/runtime/vm/json_stream.cc |
| +++ b/runtime/vm/json_stream.cc |
| @@ -822,8 +822,14 @@ bool JSONStream::AddDartString(const String& s, |
| } |
| intptr_t limit = offset + count; |
| for (intptr_t i = offset; i < limit; i++) { |
| - intptr_t code_unit = s.CharAt(i); |
| - buffer_.EscapeAndAddCodeUnit(code_unit); |
| + uint32_t code_unit = s.CharAt(i); |
| + ASSERT(!Utf16::IsTrailSurrogate(code_unit)); |
| + if (Utf16::IsLeadSurrogate(code_unit)) { |
| + uint32_t trail = s.CharAt(++i); |
|
rmacnak
2016/06/21 16:56:56
A Dart string may have unmatched surrogates, so th
cbernaschina
2016/06/21 21:24:43
Done.
|
| + buffer_.EscapeAndAddCodeUnit(Utf16::Decode(code_unit, trail)); |
| + } else { |
| + buffer_.EscapeAndAddCodeUnit(code_unit); |
| + } |
| } |
| // Return value indicates whether the string is truncated. |
| return (offset > 0) || (limit < length); |