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

Unified Diff: runtime/lib/vmservice.cc

Issue 2629533002: Fix leak of message snapshot buffer when attempting to send an illegal object. (Closed)
Patch Set: Created 3 years, 11 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 | « runtime/lib/isolate.cc ('k') | runtime/vm/benchmark_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/vmservice.cc
diff --git a/runtime/lib/vmservice.cc b/runtime/lib/vmservice.cc
index 5b6af4f707ce598da661873e44ac8f1b94610d15..9d83c13b9d8e421a7bb7b734f77843d561c7e655 100644
--- a/runtime/lib/vmservice.cc
+++ b/runtime/lib/vmservice.cc
@@ -21,11 +21,17 @@ namespace dart {
DECLARE_FLAG(bool, trace_service);
-static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
+static uint8_t* malloc_allocator(uint8_t* ptr,
+ intptr_t old_size,
+ intptr_t new_size) {
void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
return reinterpret_cast<uint8_t*>(new_ptr);
}
+static void malloc_deallocator(uint8_t* ptr) {
+ free(reinterpret_cast<void*>(ptr));
+}
+
#ifndef PRODUCT
class RegisterRunningIsolatesVisitor : public IsolateVisitor {
@@ -95,7 +101,7 @@ DEFINE_NATIVE_ENTRY(VMService_SendIsolateServiceMessage, 2) {
// Serialize message.
uint8_t* data = NULL;
- MessageWriter writer(&data, &allocator, false);
+ MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false);
writer.WriteMessage(message);
// TODO(turnidge): Throw an exception when the return value is false?
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/benchmark_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698