diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp index e7abce35d2..798cfb2c5f 100644 --- a/Kernel/Task.cpp +++ b/Kernel/Task.cpp @@ -243,6 +243,9 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren }; bool success = space.loadELF(move(elfData)); if (!success) { + // FIXME: This is ugly. If we need to do this, it should be at a different level. + MemoryManager::the().unmapRegionsForTask(*t); + MemoryManager::the().mapRegionsForTask(*current); delete t; kprintf("Failure loading ELF %s\n", path.characters()); error = -ENOEXEC; @@ -251,11 +254,15 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren t->m_tss.eip = (dword)space.symbolPtr("_start"); if (!t->m_tss.eip) { + // FIXME: This is ugly. If we need to do this, it should be at a different level. + MemoryManager::the().unmapRegionsForTask(*t); + MemoryManager::the().mapRegionsForTask(*current); delete t; error = -ENOEXEC; return nullptr; } + // FIXME: This is ugly. If we need to do this, it should be at a different level. MemoryManager::the().unmapRegionsForTask(*t); MemoryManager::the().mapRegionsForTask(*current);