From 9704acb982eb3dfb4b2b6a090f5613d4ac57b196 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 6 Dec 2022 16:13:42 -0500 Subject: general: improve handling of system startup failure --- src/core/hle/kernel/kernel.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 288f97df5..0eb74a422 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -104,12 +104,16 @@ struct KernelCore::Impl { } void CloseCurrentProcess() { - (*current_process).Finalize(); - // current_process->Close(); - // TODO: The current process should be destroyed based on accurate ref counting after + KProcess* old_process = current_process.exchange(nullptr); + if (old_process == nullptr) { + return; + } + + // old_process->Close(); + // TODO: The process should be destroyed based on accurate ref counting after // calling Close(). Adding a manual Destroy() call instead to avoid a memory leak. - (*current_process).Destroy(); - current_process = nullptr; + old_process->Finalize(); + old_process->Destroy(); } void Shutdown() { -- cgit v1.2.3