From 51ceb172b9a87da7b6477e202d47c9c9316dc408 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Wed, 12 May 2021 23:36:25 -0700 Subject: [PATCH] Kernel: Replace make() with adopt_own_if_nonnull() in sys$module_load --- Kernel/Syscalls/module.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Kernel/Syscalls/module.cpp b/Kernel/Syscalls/module.cpp index ceaf8601c2..de12de98e3 100644 --- a/Kernel/Syscalls/module.cpp +++ b/Kernel/Syscalls/module.cpp @@ -37,13 +37,17 @@ KResultOr Process::sys$module_load(Userspace user_path, size_t auto storage = KBuffer::create_with_size(payload.size()); memcpy(storage.data(), payload.data(), payload.size()); - auto elf_image = make(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 section_storage_by_name; - auto module = make(); + 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())