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

Unified Diff: runtime/lib/isolate.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 | « no previous file | runtime/lib/vmservice.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate.cc
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc
index d88fbc8c5d6f8c10eb034326e417ce54501e0270..4eff30795a604e3d295aebcad0fc1e90b57a8fce 100644
--- a/runtime/lib/isolate.cc
+++ b/runtime/lib/isolate.cc
@@ -30,11 +30,17 @@ DEFINE_FLAG(bool,
false,
"Block the parent thread when loading spawned isolates.");
-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));
+}
+
DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) {
ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull());
@@ -116,7 +122,8 @@ DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 2) {
new Message(destination_port_id, obj.raw(), Message::kNormalPriority));
} else {
uint8_t* data = NULL;
- MessageWriter writer(&data, &allocator, can_send_any_object);
+ MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator,
+ can_send_any_object);
writer.WriteMessage(obj);
// TODO(turnidge): Throw an exception when the return value is false?
@@ -424,7 +431,7 @@ DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) {
msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg)));
uint8_t* data = NULL;
- MessageWriter writer(&data, &allocator, false);
+ MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false);
writer.WriteMessage(msg);
PortMap::PostMessage(new Message(port.Id(), data, writer.BytesWritten(),
« no previous file with comments | « no previous file | runtime/lib/vmservice.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698