1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:48:10 +00:00

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
parent 2f010e941c
commit 55c722096d

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