[PATCH 1/5] kernel32: Return TRUE from GlobalUnlock on invalid handle error.
Rémi Bernon
rbernon at codeweavers.com
Fri Apr 1 03:22:57 CDT 2022
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/kernel32/heap.c | 4 +++-
dlls/kernel32/tests/heap.c | 1 -
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c
index dbb240d89fc..9cce4402aed 100644
--- a/dlls/kernel32/heap.c
+++ b/dlls/kernel32/heap.c
@@ -234,8 +234,10 @@ void *WINAPI GlobalLock( HGLOBAL handle )
*/
BOOL WINAPI GlobalUnlock( HGLOBAL handle )
{
+ BOOL ret;
if (unsafe_ptr_from_HLOCAL( handle )) return TRUE;
- return LocalUnlock( handle );
+ if ((ret = LocalUnlock( handle )) || !GetLastError()) return ret;
+ return GetLastError() != ERROR_NOT_LOCKED;
}
diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c
index 476be96cea8..25f5e367e7c 100644
--- a/dlls/kernel32/tests/heap.c
+++ b/dlls/kernel32/tests/heap.c
@@ -524,7 +524,6 @@ static void test_GlobalAlloc(void)
ok( GetLastError() == ERROR_INVALID_HANDLE, "got error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = GlobalUnlock( mem );
- todo_wine
ok( ret, "GlobalUnlock failed, error %lu\n", GetLastError() );
ok( GetLastError() == ERROR_INVALID_HANDLE, "got error %lu\n", GetLastError() );
#if 0 /* corrupts Wine heap */
--
2.35.1
More information about the wine-devel
mailing list