Fix some easy leaks reported by asan.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3411 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2017-11-18 23:02:08 +00:00
parent 0ef8a8919a
commit 2bc62b2ecd
3 changed files with 7 additions and 1 deletions

View File

@ -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<char*>(buffer->base);
} else {
owner->close();
}
delete[] reinterpret_cast<char*>(buffer->base);
}
void PacketStream::processMessages() {

View File

@ -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;
}

View File

@ -103,6 +103,8 @@ private:
v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > _exportObject;
v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> > _sourceObject;
v8::ArrayBuffer::Allocator* _allocator;
v8::Handle<v8::Object> getStatistics();
std::string resolveRequire(const std::string& require);