1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 10:18:15 +09:00

Kernel: Make ProcessGroup::find_or_create API OOM safe

Make ProcessGroup::find_or_create & ProcessGroup::create OOM safe, by
moving to adopt_ref_if_nonnull.
This commit is contained in:
Brian Gianforcaro 2021-05-18 02:07:25 -07:00 committed by Andreas Kling
parent 7540f4268b
commit bb91bed576
Notes: sideshowbarker 2024-07-18 17:43:49 +09:00
3 changed files with 9 additions and 6 deletions

View file

@ -17,10 +17,10 @@ ProcessGroup::~ProcessGroup()
g_process_groups->remove(this);
}
NonnullRefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
RefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
{
auto process_group = adopt_ref(*new ProcessGroup(pgid));
{
auto process_group = adopt_ref_if_nonnull(new ProcessGroup(pgid));
if (process_group) {
ScopedSpinLock lock(g_process_groups_lock);
g_process_groups->prepend(process_group);
}
@ -28,7 +28,7 @@ NonnullRefPtr<ProcessGroup> ProcessGroup::create(ProcessGroupID pgid)
return process_group;
}
NonnullRefPtr<ProcessGroup> ProcessGroup::find_or_create(ProcessGroupID pgid)
RefPtr<ProcessGroup> ProcessGroup::find_or_create(ProcessGroupID pgid)
{
ScopedSpinLock lock(g_process_groups_lock);