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

Unified Diff: runtime/vm/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 | « runtime/vm/datastream.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 76159c82423aeefb25f5ca47c425e3f0af095df2..ef8dd9cca1d89259c56eae8775dd443499441f94 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -100,17 +100,24 @@ class VerifyOriginId : public IsolateVisitor {
#endif
-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));
+}
+
static void SerializeObject(const Instance& obj,
uint8_t** obj_data,
intptr_t* obj_len,
bool allow_any_object) {
- MessageWriter writer(obj_data, &allocator, allow_any_object);
+ MessageWriter writer(obj_data, &malloc_allocator, &malloc_deallocator,
+ allow_any_object);
writer.WriteMessage(obj);
*obj_len = writer.BytesWritten();
}
@@ -193,7 +200,7 @@ void Isolate::SendInternalLibMessage(LibMsgId msg_id, uint64_t capability) {
msg.SetAt(2, element);
uint8_t* data = NULL;
- MessageWriter writer(&data, &allocator, false);
+ MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false);
writer.WriteMessage(msg);
PortMap::PostMessage(new Message(main_port(), data, writer.BytesWritten(),
@@ -2556,7 +2563,7 @@ void Isolate::KillLocked(LibMsgId msg_id) {
{
uint8_t* buffer = NULL;
- ApiMessageWriter writer(&buffer, allocator);
+ ApiMessageWriter writer(&buffer, &malloc_allocator);
bool success = writer.WriteCMessage(&kill_msg);
ASSERT(success);
« no previous file with comments | « runtime/vm/datastream.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698