From 8a320a6ee2d803f607655206d0f3315d4e7c9f57 Mon Sep 17 00:00:00 2001
From: Fernando Sahmkow <fsahmkow27@gmail.com>
Date: Tue, 19 Mar 2019 22:45:34 -0400
Subject: [PATCH] Fix crash caused by 2238.

---
 src/core/hle/kernel/thread.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index d9ffebc3f..3b22e8e0d 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -314,8 +314,9 @@ void Thread::UpdatePriority() {
     }
 
     // Ensure that the thread is within the correct location in the waiting list.
+    auto old_owner = lock_owner;
     lock_owner->RemoveMutexWaiter(this);
-    lock_owner->AddMutexWaiter(this);
+    old_owner->AddMutexWaiter(this);
 
     // Recursively update the priority of the thread that depends on the priority of this one.
     lock_owner->UpdatePriority();