1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:57:44 +00:00

Fix crash when process spawn fails.

This commit is contained in:
Andreas Kling 2018-11-01 12:55:06 +01:00
parent c178d7a9e3
commit 8525cdd6a2

View file

@ -307,7 +307,8 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren
}; };
bool success = space.loadELF(move(elfData)); bool success = space.loadELF(move(elfData));
if (!success) { if (!success) {
MM.remove_kernel_alias_for_region(*region, region_alias); if (region)
MM.remove_kernel_alias_for_region(*region, region_alias);
delete t; delete t;
kprintf("Failure loading ELF %s\n", path.characters()); kprintf("Failure loading ELF %s\n", path.characters());
error = -ENOEXEC; error = -ENOEXEC;
@ -332,12 +333,14 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren
t->m_tss.eip = (dword)space.symbolPtr("_start"); t->m_tss.eip = (dword)space.symbolPtr("_start");
if (!t->m_tss.eip) { if (!t->m_tss.eip) {
// FIXME: This is ugly. If we need to do this, it should be at a different level. // FIXME: This is ugly. If we need to do this, it should be at a different level.
MM.remove_kernel_alias_for_region(*region, region_alias); if (region)
MM.remove_kernel_alias_for_region(*region, region_alias);
delete t; delete t;
error = -ENOEXEC; error = -ENOEXEC;
return nullptr; return nullptr;
} }
ASSERT(region);
MM.remove_kernel_alias_for_region(*region, region_alias); MM.remove_kernel_alias_for_region(*region, region_alias);
MM.mapRegionsForTask(*t); MM.mapRegionsForTask(*t);