Kernel: Make Space::create API OOM safe

This commit is contained in:
Brian Gianforcaro 2021-05-28 05:05:30 -07:00 committed by Andreas Kling
parent d570048c9e
commit 8fc6168f21
Notes: sideshowbarker 2024-07-18 17:15:07 +09:00

View file

@ -20,7 +20,9 @@ OwnPtr<Space> Space::create(Process& process, const Space* parent)
auto page_directory = PageDirectory::create_for_userspace(parent ? &parent->page_directory().range_allocator() : nullptr);
if (!page_directory)
return {};
auto space = adopt_own(*new Space(process, page_directory.release_nonnull()));
auto space = adopt_own_if_nonnull(new Space(process, page_directory.release_nonnull()));
if (!space)
return {};
space->page_directory().set_space({}, *space);
return space;
}