From 879efb25cc168f93383ac2cbef32637e678efd43 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 21 Nov 2012 00:28:29 -0800 Subject: [PATCH] Don't allow unlocking someone else's mutex. --- Core/HLE/sceKernelMutex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 5a7002b827..f5530567b2 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -435,7 +435,7 @@ void sceKernelUnlockMutex(SceUID id, int count) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; else if ((mutex->nm.attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && count > 1) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; - else if (mutex->nm.lockLevel == 0) + else if (mutex->nm.lockLevel == 0 || mutex->nm.lockThread != __KernelGetCurThread()) error = PSP_MUTEX_ERROR_NOT_LOCKED; else if (mutex->nm.lockLevel < count) error = PSP_MUTEX_ERROR_UNLOCK_UNDERFLOW; @@ -787,7 +787,7 @@ void sceKernelUnlockLwMutex(u32 workareaPtr, int count) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; else if ((workarea.attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && count > 1) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; - else if (workarea.lockLevel == 0) + else if (workarea.lockLevel == 0 || workarea.lockThread != __KernelGetCurThread()) error = PSP_LWMUTEX_ERROR_NOT_LOCKED; else if (workarea.lockLevel < count) error = PSP_LWMUTEX_ERROR_UNLOCK_UNDERFLOW;