Process::create_user_process() shouldn't leak a process if exec() fails.

This commit is contained in:
Andreas Kling 2018-12-26 21:04:27 +01:00
commit 55c722096d
Notes: sideshowbarker 2024-07-19 16:07:02 +09:00

View file

@ -489,8 +489,10 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid,
auto* process = new Process(parts.takeLast(), uid, gid, parent_pid, Ring3, move(cwd), nullptr, tty);
error = process->exec(path, move(arguments), move(environment));
if (error != 0)
if (error != 0) {
delete process;
return nullptr;
}
ProcFS::the().add_process(*process);