Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1246)

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 1412193007: Fix Dart_GlobalTimelineGetTrace to null terminate the string (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698