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())