diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-08-26 06:38:29 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-08-26 06:39:05 -0400 |
| commit | 9fac03b84c08bc5a453f04e87b892ccf408ee9c2 (patch) | |
| tree | f605e773c4451cec0a84214675fcaeecb4cd94b6 /core/thread/thread_pool.odin | |
| parent | 0a8f85e8798c097500d4f898fd9d49c81893a53d (diff) | |
Fix use-after-free in `thread.Pool`
Diffstat (limited to 'core/thread/thread_pool.odin')
| -rw-r--r-- | core/thread/thread_pool.odin | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/thread/thread_pool.odin b/core/thread/thread_pool.odin index da5e116ff..7e2489013 100644 --- a/core/thread/thread_pool.odin +++ b/core/thread/thread_pool.odin @@ -175,10 +175,12 @@ pool_stop_task :: proc(pool: ^Pool, user_index: int, exit_code: int = 1) -> bool intrinsics.atomic_sub(&pool.num_outstanding, 1) intrinsics.atomic_sub(&pool.num_in_processing, 1) + old_thread_user_index := t.user_index + destroy(t) replacement := create(pool_thread_runner) - replacement.user_index = t.user_index + replacement.user_index = old_thread_user_index replacement.data = data data.task = {} pool.threads[i] = replacement @@ -207,10 +209,12 @@ pool_stop_all_tasks :: proc(pool: ^Pool, exit_code: int = 1) { intrinsics.atomic_sub(&pool.num_outstanding, 1) intrinsics.atomic_sub(&pool.num_in_processing, 1) + old_thread_user_index := t.user_index + destroy(t) replacement := create(pool_thread_runner) - replacement.user_index = t.user_index + replacement.user_index = old_thread_user_index replacement.data = data data.task = {} pool.threads[i] = replacement |