1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

Kernel: Replace make<T>() with adopt_own_if_nonnull() in sys$module_load

This commit is contained in:
Brian Gianforcaro 2021-05-12 23:36:25 -07:00 committed by Andreas Kling
parent 9ca8f0afaa
commit 51ceb172b9

View file

@ -37,13 +37,17 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t
auto storage = KBuffer::create_with_size(payload.size());
memcpy(storage.data(), payload.data(), payload.size());
auto elf_image = make<ELF::Image>(storage.data(), storage.size());
auto elf_image = adopt_own_if_nonnull(new ELF::Image(storage.data(), storage.size()));
if (!elf_image)
return ENOMEM;
if (!elf_image->parse())
return ENOEXEC;
HashMap<String, u8*> section_storage_by_name;
auto module = make<Module>();
auto module = adopt_own_if_nonnull(new Module());
if (!module)
return ENOMEM;
elf_image->for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) {
if (!section.size())