mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
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.
This commit is contained in:
parent
602a830428
commit
9e32d79e02
Notes:
sideshowbarker
2024-07-19 01:08:32 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/9e32d79e02c Pull-request: https://github.com/SerenityOS/serenity/pull/4280
1 changed files with 1 additions and 1 deletions
|
@ -60,7 +60,7 @@ int Process::sys$create_thread(void* (*entry)(void*), Userspace<const Syscall::S
|
|||
|
||||
// FIXME: Do something with guard pages?
|
||||
|
||||
auto* thread = new Thread(*this);
|
||||
auto thread = adopt(*new Thread(*this));
|
||||
|
||||
// We know this thread is not the main_thread,
|
||||
// So give it a unique name until the user calls $set_thread_name on it
|
||||
|
|
Loading…
Add table
Reference in a new issue