mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
Kernel: Make Thread::try_create API OOM safe
This commit is contained in:
parent
d07309a180
commit
112393b38a
Notes:
sideshowbarker
2024-07-18 18:15:56 +09:00
Author: https://github.com/bgianfo
Commit: 112393b38a
Pull-request: https://github.com/SerenityOS/serenity/pull/7026
1 changed files with 6 additions and 1 deletions
|
@ -41,7 +41,12 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce
|
||||||
if (!kernel_stack_region)
|
if (!kernel_stack_region)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
kernel_stack_region->set_stack(true);
|
kernel_stack_region->set_stack(true);
|
||||||
return adopt_ref(*new Thread(move(process), kernel_stack_region.release_nonnull()));
|
|
||||||
|
auto thread = adopt_ref_if_nonnull(new Thread(move(process), kernel_stack_region.release_nonnull()));
|
||||||
|
if (!thread)
|
||||||
|
return ENOMEM;
|
||||||
|
|
||||||
|
return thread.release_nonnull();
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Region> kernel_stack_region)
|
Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Region> kernel_stack_region)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue