diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-12-26 21:04:27 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-12-26 21:04:27 +0100 |
commit | 55c722096da724ba93f0a2c5e1f4cb1f59cf9f0e (patch) | |
tree | 0bd14ea656b6e23bdb45ac4535de62c933cf70d6 /Kernel | |
parent | 2f010e941c80d6527bd14f75fa1bff73b700a6af (diff) | |
download | serenity-55c722096da724ba93f0a2c5e1f4cb1f59cf9f0e.zip |
Process::create_user_process() shouldn't leak a process if exec() fails.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index c41cce5f84..3d7cc43521 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -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); |