| Index: runtime/vm/dart_api_impl.cc
|
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
|
| index 1d7ed040c31215268425e90bbf18cd09c30b4b1e..85ea50999155c8a81f5db89c49814ea0fa981711 100644
|
| --- a/runtime/vm/dart_api_impl.cc
|
| +++ b/runtime/vm/dart_api_impl.cc
|
| @@ -5806,13 +5806,26 @@ static bool StreamTraceEvents(Dart_StreamConsumer consumer,
|
| char* output = NULL;
|
| intptr_t output_length = 0;
|
| js->Steal(const_cast<const char**>(&output), &output_length);
|
| + if (output_length < 3) {
|
| + // Empty JSON array.
|
| + free(output);
|
| + return false;
|
| + }
|
| + // We want to send the JSON array without the leading '[' or trailing ']'
|
| + // characters.
|
| + ASSERT(output[0] == '[');
|
| + ASSERT(output[output_length - 1] == ']');
|
| + // Replace the ']' with the null character.
|
| + output[output_length - 1] = '\0';
|
| + // We are skipping the '['.
|
| + output_length -= 1;
|
|
|
| // Start the stream.
|
| StartStreamToConsumer(consumer, user_data, "timeline");
|
|
|
| DataStreamToConsumer(consumer,
|
| user_data,
|
| - output,
|
| + &output[1],
|
| output_length,
|
| "timeline");
|
|
|
|
|