From 55650c5b756d81054669974a3098aff3114309c0 Mon Sep 17 00:00:00 2001
From: ameerj <52414509+ameerj@users.noreply.github.com>
Date: Sun, 19 Dec 2021 01:38:25 -0500
Subject: [PATCH] kernel: Manually destroy the current process during shut down

Avoids a memory leak.
---
 src/core/hle/kernel/kernel.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 2e4e4cb1cc..1225e1fbad 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -182,7 +182,10 @@ struct KernelCore::Impl {
         // Shutdown all processes.
         if (current_process) {
             current_process->Finalize();
-            current_process->Close();
+            // current_process->Close();
+            // TODO: The current 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;
         }