kernel32: Fix return code from LocalUnlock for pointer passed to it.
This commit is contained in:
parent
9494cdc56f
commit
0597e659bd
|
@ -1116,7 +1116,14 @@ SIZE_T WINAPI LocalSize(
|
|||
*/
|
||||
BOOL WINAPI LocalUnlock(
|
||||
HLOCAL handle /* [in] Handle of memory object */
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (ISPOINTER( handle ))
|
||||
{
|
||||
SetLastError( ERROR_NOT_LOCKED );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return GlobalUnlock( handle );
|
||||
}
|
||||
|
||||
|
|
|
@ -249,14 +249,27 @@ static void test_heap(void)
|
|||
|
||||
res = GlobalUnlock(gbl);
|
||||
ok(res == 1 ||
|
||||
res == 0, /* win9x */
|
||||
broken(res == 0), /* win9x */
|
||||
"Expected 1 or 0, got %d\n", res);
|
||||
|
||||
res = GlobalUnlock(gbl);
|
||||
ok(res == 1 ||
|
||||
res == 0, /* win9x */
|
||||
broken(res == 0), /* win9x */
|
||||
"Expected 1 or 0, got %d\n", res);
|
||||
|
||||
GlobalFree(gbl);
|
||||
|
||||
gbl = GlobalAlloc(GMEM_FIXED, 100);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
res = GlobalUnlock(gbl);
|
||||
ok(res == 1 ||
|
||||
broken(res == 0), /* win9x */
|
||||
"Expected 1 or 0, got %d\n", res);
|
||||
ok(GetLastError() == 0xdeadbeef, "got %d\n", GetLastError());
|
||||
|
||||
GlobalFree(gbl);
|
||||
|
||||
/* GlobalSize on an invalid handle */
|
||||
if (sizeof(void *) != 8) /* crashes on 64-bit Vista */
|
||||
{
|
||||
|
@ -268,8 +281,6 @@ static void test_heap(void)
|
|||
"Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||
}
|
||||
|
||||
GlobalFree(gbl);
|
||||
|
||||
/* ####################################### */
|
||||
/* Local*() functions */
|
||||
gbl = LocalAlloc(LMEM_MOVEABLE, 0);
|
||||
|
@ -371,6 +382,15 @@ static void test_heap(void)
|
|||
"returned %d with %d (expected '0' with ERROR_INVALID_HANDLE)\n",
|
||||
res, GetLastError());
|
||||
|
||||
/* trying to unlock pointer from LocalAlloc */
|
||||
gbl = LocalAlloc(LMEM_FIXED, 100);
|
||||
SetLastError(0xdeadbeef);
|
||||
res = LocalUnlock(gbl);
|
||||
ok(res == 0, "Expected 0, got %d\n", res);
|
||||
ok(GetLastError() == ERROR_NOT_LOCKED ||
|
||||
broken(GetLastError() == 0xdeadbeef) /* win9x */, "got %d\n", GetLastError());
|
||||
LocalFree(gbl);
|
||||
|
||||
/* trying to lock empty memory should give an error */
|
||||
gbl = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,0);
|
||||
ok(gbl != NULL, "returned NULL\n");
|
||||
|
|
Loading…
Reference in New Issue