kernel32: Don't crash accessing an invalid handle in GlobalSize.
This commit is contained in:
parent
b095ade908
commit
8e90c6099e
|
@ -807,7 +807,11 @@ SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
|
|||
DWORD retval;
|
||||
PGLOBAL32_INTERN pintern;
|
||||
|
||||
if (!hmem) return 0;
|
||||
if (!((ULONG_PTR)hmem >> 16))
|
||||
{
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(ISPOINTER(hmem))
|
||||
{
|
||||
|
|
|
@ -197,6 +197,13 @@ START_TEST(heap)
|
|||
res = GlobalUnlock(gbl);
|
||||
ok(res == 1, "Expected 1, got %d\n", res);
|
||||
|
||||
/* GlobalSize on an invalid handle */
|
||||
SetLastError(MAGIC_DEAD);
|
||||
size = GlobalSize((HGLOBAL)0xc042);
|
||||
ok(size == 0, "Expected 0, got %ld\n", size);
|
||||
ok(GetLastError() == ERROR_INVALID_HANDLE,
|
||||
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
|
||||
|
||||
/* ####################################### */
|
||||
/* Local*() functions */
|
||||
gbl = LocalAlloc(LMEM_MOVEABLE, 0);
|
||||
|
|
Loading…
Reference in New Issue