From c9f44360733973e2bf8658acc4db0ce5e88a3dd2 Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 27 Jul 2024 21:24:08 +0800 Subject: [PATCH] Fix use-after-free in WorkerThreadPool --- core/object/worker_thread_pool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp index a873bc1f09c..56b9fa84756 100644 --- a/core/object/worker_thread_pool.cpp +++ b/core/object/worker_thread_pool.cpp @@ -83,6 +83,10 @@ void WorkerThreadPool::_process_task(Task *p_task) { } #endif +#ifdef THREADS_ENABLED + bool low_priority = p_task->low_priority; +#endif + if (p_task->group) { // Handling a group bool do_post = false; @@ -159,7 +163,7 @@ void WorkerThreadPool::_process_task(Task *p_task) { #ifdef THREADS_ENABLED { curr_thread.current_task = prev_task; - if (p_task->low_priority) { + if (low_priority) { low_priority_threads_used--; if (_try_promote_low_priority_task()) {