mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Kernel: Stop leaking executable path in successful sys$execve()
Since we don't return from sys$execve() when it's successful, we have to take special care to tear down anything we've allocated. Turns out we were not doing this for the full executable path itself.
This commit is contained in:
parent
611733af0d
commit
8ad46fd8f5
1 changed files with 6 additions and 0 deletions
|
@ -840,6 +840,12 @@ ErrorOr<void> Process::exec(NonnullOwnPtr<KString> path, NonnullOwnPtrVector<KSt
|
|||
|
||||
auto* current_thread = Thread::current();
|
||||
if (current_thread == new_main_thread) {
|
||||
{
|
||||
// Make sure that `path` gets deleted before we teleport into the new process.
|
||||
// If we don't do this, it will leak (since we never return from this function.)
|
||||
OwnPtr<KString> path_deleter = move(path);
|
||||
}
|
||||
|
||||
// We need to enter the scheduler lock before changing the state
|
||||
// and it will be released after the context switch into that
|
||||
// thread. We should also still be in our critical section
|
||||
|
|
Loading…
Add table
Reference in a new issue