From 9e32d79e02c84c0130c9fe1b143b445ac9093079 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 30 Nov 2020 16:10:51 -0700 Subject: [PATCH] Kernel: Fix leaking a reference on thread creation New Thread objects should be adopted into a RefPtr upon creation. If creating a thread failed (e.g. out of memory), releasing the RefPtr will destruct the partially created object, but in the successful case the thread will add an additional reference that it keeps until it finishes execution. Adopting will drop it to 1 when returning from create_thread, or 0 if the thread could not be fully constructed. --- Kernel/Syscalls/thread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Syscalls/thread.cpp b/Kernel/Syscalls/thread.cpp index 9781ab0e72..0e8a9be788 100644 --- a/Kernel/Syscalls/thread.cpp +++ b/Kernel/Syscalls/thread.cpp @@ -60,7 +60,7 @@ int Process::sys$create_thread(void* (*entry)(void*), Userspace