reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 8152f4652a7f0554b49f22d6470a9aa6c0f27850
parent 8f8730c69f311094e2b449f546d14e4fca7c037c
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Thu, 25 Oct 2018 16:44:43 -0400

fix use-after-free when destroying background tasks from the thread pool

Same mistake as in bf27e9c6324f6ce2b32e3e19a8fe65d8d8aa9b7b.

Diffstat:
Msrc/thread.cpp | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/thread.cpp b/src/thread.cpp @@ -132,11 +132,13 @@ void ThreadPool::push(ThreadTask *task) task->onFinishAsync >> [=] { m_running.erase(task); + // 'this' (captured variable) isn't valid after the delete below + ThreadPool *self = this; delete task; // call m_onDone() only after every onFinish slots ran - if(m_running.empty()) - onDone(); + if(self->m_running.empty()) + self->onDone(); }; const size_t nextThread = m_running.size() % m_pool.size();