From 2bc62b2ecd968b38471dc54813175c9288b3323f Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 18 Nov 2017 23:02:08 +0000 Subject: [PATCH] Fix some easy leaks reported by asan. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3411 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/PacketStream.cpp | 2 +- src/Task.cpp | 4 ++++ src/Task.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PacketStream.cpp b/src/PacketStream.cpp index 13013e01..201d30fa 100644 --- a/src/PacketStream.cpp +++ b/src/PacketStream.cpp @@ -60,10 +60,10 @@ void PacketStream::onRead(uv_stream_t* handle, ssize_t count, const uv_buf_t* bu owner->_buffer.insert(owner->_buffer.end(), buffer->base, buffer->base + count); owner->processMessages(); } - delete[] reinterpret_cast(buffer->base); } else { owner->close(); } + delete[] reinterpret_cast(buffer->base); } void PacketStream::processMessages() { diff --git a/src/Task.cpp b/src/Task.cpp index 78199dfc..243bf16a 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -98,6 +98,7 @@ Task::Task() { ++_count; v8::Isolate::CreateParams options; options.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); + _allocator = options.array_buffer_allocator; _isolate = v8::Isolate::New(options); _isolate->SetData(0, this); _isolate->SetCaptureStackTraceForUncaughtExceptions(true, 16); @@ -117,6 +118,9 @@ Task::~Task() { _isolate->Dispose(); _isolate = 0; + delete _allocator; + _allocator = nullptr; + uv_loop_delete(_loop); --_count; } diff --git a/src/Task.h b/src/Task.h index 3317c8ee..81d4a40e 100644 --- a/src/Task.h +++ b/src/Task.h @@ -103,6 +103,8 @@ private: v8::Persistent > _exportObject; v8::Persistent > _sourceObject; + v8::ArrayBuffer::Allocator* _allocator; + v8::Handle getStatistics(); std::string resolveRequire(const std::string& require);