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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 5788 matching lines...) Expand 10 before | Expand all | Expand 10 after
5799 5799
5800 5800
5801 static bool StreamTraceEvents(Dart_StreamConsumer consumer, 5801 static bool StreamTraceEvents(Dart_StreamConsumer consumer,
5802 void* user_data, 5802 void* user_data,
5803 JSONStream* js) { 5803 JSONStream* js) {
5804 ASSERT(js != NULL); 5804 ASSERT(js != NULL);
5805 // Steal output from JSONStream. 5805 // Steal output from JSONStream.
5806 char* output = NULL; 5806 char* output = NULL;
5807 intptr_t output_length = 0; 5807 intptr_t output_length = 0;
5808 js->Steal(const_cast<const char**>(&output), &output_length); 5808 js->Steal(const_cast<const char**>(&output), &output_length);
5809 if (output_length < 3) {
5810 // Empty JSON array.
5811 free(output);
5812 return false;
5813 }
5814 // We want to send the JSON array without the leading '[' or trailing ']'
5815 // characters.
5816 ASSERT(output[0] == '[');
5817 ASSERT(output[output_length - 1] == ']');
5818 // Replace the ']' with the null character.
5819 output[output_length - 1] = '\0';
5820 // We are skipping the '['.
5821 output_length -= 1;
5809 5822
5810 // Start the stream. 5823 // Start the stream.
5811 StartStreamToConsumer(consumer, user_data, "timeline"); 5824 StartStreamToConsumer(consumer, user_data, "timeline");
5812 5825
5813 DataStreamToConsumer(consumer, 5826 DataStreamToConsumer(consumer,
5814 user_data, 5827 user_data,
5815 output, 5828 &output[1],
5816 output_length, 5829 output_length,
5817 "timeline"); 5830 "timeline");
5818 5831
5819 // We stole the JSONStream's output buffer, free it. 5832 // We stole the JSONStream's output buffer, free it.
5820 free(output); 5833 free(output);
5821 5834
5822 // Finish the stream. 5835 // Finish the stream.
5823 FinishStreamToConsumer(consumer, user_data, "timeline"); 5836 FinishStreamToConsumer(consumer, user_data, "timeline");
5824 return true; 5837 return true;
5825 } 5838 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
6031 ApiReallocate); 6044 ApiReallocate);
6032 writer.WriteFullSnapshot(); 6045 writer.WriteFullSnapshot();
6033 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); 6046 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
6034 *isolate_snapshot_size = writer.IsolateSnapshotSize(); 6047 *isolate_snapshot_size = writer.IsolateSnapshotSize();
6035 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); 6048 *instructions_snapshot_size = writer.InstructionsSnapshotSize();
6036 6049
6037 return Api::Success(); 6050 return Api::Success();
6038 } 6051 }
6039 6052
6040 } // namespace dart 6053 } // namespace dart
OLDNEW
« 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