Commit 8e90c609 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

kernel32: Don't crash accessing an invalid handle in GlobalSize.

parent b095ade9
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment