| Index: runtime/vm/json_stream.cc
|
| diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
|
| index 2f92daa709accae3701713cb888e7425715d1677..88a72b676ded97964937e7ba88b6312f7a8264bf 100644
|
| --- a/runtime/vm/json_stream.cc
|
| +++ b/runtime/vm/json_stream.cc
|
| @@ -30,7 +30,9 @@ JSONStream::JSONStream(intptr_t buf_size)
|
| method_(""),
|
| param_keys_(NULL),
|
| param_values_(NULL),
|
| - num_params_(0) {
|
| + num_params_(0),
|
| + offset_(0),
|
| + count_(-1) {
|
| ObjectIdRing* ring = NULL;
|
| Isolate* isolate = Isolate::Current();
|
| if (isolate != NULL) {
|
| @@ -245,6 +247,22 @@ bool JSONStream::ParamIs(const char* key, const char* value) const {
|
| }
|
|
|
|
|
| +void JSONStream::ComputeOffsetAndCount(intptr_t length,
|
| + intptr_t* offset,
|
| + intptr_t* count) {
|
| + // This function is written to avoid adding (count + offset) in case
|
| + // that triggers an integer overflow.
|
| + *offset = offset_;
|
| + if (*offset > length) {
|
| + *offset = length;
|
| + }
|
| + intptr_t remaining = length - *offset;
|
| + *count = count_;
|
| + if (*count < 0 || *count > remaining) {
|
| + *count = remaining;
|
| + }
|
| +}
|
| +
|
| void JSONStream::Clear() {
|
| buffer_.Clear();
|
| open_objects_ = 0;
|
|
|