From c63ea608aa10b35c7b3cd418cbbc3df8d8bbde73 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 9 Jun 2021 15:24:46 -0700 Subject: [PATCH] kernel: svc: Add missing error check to CancelSynchronization. - Avoids a potential crash if the handle is invalid, and also makes this code accurate to real kernel behavior. --- src/core/hle/kernel/svc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 28bcae6e7..8339e11a0 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -449,8 +449,8 @@ static ResultCode CancelSynchronization(Core::System& system, Handle handle) { // Get the thread from its handle. KScopedAutoObject thread = - system.Kernel().CurrentProcess()->GetHandleTable().GetObject( - static_cast(handle)); + system.Kernel().CurrentProcess()->GetHandleTable().GetObject(handle); + R_UNLESS(thread.IsNotNull(), ResultInvalidHandle); // Cancel the thread's wait. thread->WaitCancel();