mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 14:20:21 +00:00
Kernel: Handle OOM from KBuffer creation in sys$module()
This commit is contained in:
parent
cbb263e350
commit
187c086270
Notes:
sideshowbarker
2024-07-18 07:31:44 +09:00
Author: https://github.com/bgianfo
Commit: 187c086270
Pull-request: https://github.com/SerenityOS/serenity/pull/9154
Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 5 additions and 3 deletions
|
@ -35,10 +35,12 @@ KResultOr<FlatPtr> Process::sys$module_load(Userspace<const char*> user_path, si
|
||||||
return payload_or_error.error();
|
return payload_or_error.error();
|
||||||
|
|
||||||
auto& payload = *payload_or_error.value();
|
auto& payload = *payload_or_error.value();
|
||||||
auto storage = KBuffer::create_with_size(payload.size());
|
auto storage = KBuffer::try_create_with_size(payload.size());
|
||||||
memcpy(storage.data(), payload.data(), payload.size());
|
if (!storage)
|
||||||
|
return ENOMEM;
|
||||||
|
memcpy(storage->data(), payload.data(), payload.size());
|
||||||
|
|
||||||
auto elf_image = try_make<ELF::Image>(storage.data(), storage.size());
|
auto elf_image = try_make<ELF::Image>(storage->data(), storage->size());
|
||||||
if (!elf_image)
|
if (!elf_image)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
if (!elf_image->parse())
|
if (!elf_image->parse())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue