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

Unified Diff: runtime/vm/snapshot.h

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/service_isolate.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot.h
diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h
index 76f48a6f0f42e269cce1f95d7284a5c07ea2d12c..03ad684235ebca4089520a950afd95134022f1c1 100644
--- a/runtime/vm/snapshot.h
+++ b/runtime/vm/snapshot.h
@@ -637,8 +637,13 @@ class BaseWriter : public StackResource {
}
protected:
- BaseWriter(uint8_t** buffer, ReAlloc alloc, intptr_t initial_size)
- : StackResource(Thread::Current()), stream_(buffer, alloc, initial_size) {
+ BaseWriter(uint8_t** buffer,
+ ReAlloc alloc,
+ DeAlloc dealloc,
+ intptr_t initial_size)
+ : StackResource(Thread::Current()),
+ stream_(buffer, alloc, initial_size),
+ dealloc_(dealloc) {
ASSERT(buffer != NULL);
ASSERT(alloc != NULL);
}
@@ -655,8 +660,11 @@ class BaseWriter : public StackResource {
data[Snapshot::kSnapshotFlagIndex] = kind;
}
+ void FreeBuffer() { dealloc_(stream_.buffer()); }
+
private:
WriteStream stream_;
+ DeAlloc dealloc_;
DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter);
};
@@ -862,6 +870,7 @@ class SnapshotWriter : public BaseWriter {
Snapshot::Kind kind,
uint8_t** buffer,
ReAlloc alloc,
+ DeAlloc dealloc,
intptr_t initial_size,
ForwardList* forward_list,
bool can_send_any_object);
@@ -992,7 +1001,10 @@ class ScriptSnapshotWriter : public SnapshotWriter {
class MessageWriter : public SnapshotWriter {
public:
static const intptr_t kInitialSize = 512;
- MessageWriter(uint8_t** buffer, ReAlloc alloc, bool can_send_any_object);
+ MessageWriter(uint8_t** buffer,
+ ReAlloc alloc,
+ DeAlloc dealloc,
+ bool can_send_any_object);
~MessageWriter() {}
void WriteMessage(const Object& obj);
« no previous file with comments | « runtime/vm/service_isolate.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698