Commit fe09e2db authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

kernel32: Change error return from GlobalFree.

parent f9181daa
...@@ -784,8 +784,8 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem) ...@@ -784,8 +784,8 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
} }
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
{ {
ERR("(%p): Page fault occurred ! Caused by bug ?\n", hmem); ERR("invalid handle %p\n", hmem);
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError(ERROR_INVALID_HANDLE);
hreturned = hmem; hreturned = hmem;
} }
__ENDTRY __ENDTRY
......
...@@ -217,6 +217,18 @@ static void test_heap(void) ...@@ -217,6 +217,18 @@ static void test_heap(void)
"returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n", "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
hsecond, GetLastError(), gbl); hsecond, GetLastError(), gbl);
SetLastError(MAGIC_DEAD); SetLastError(MAGIC_DEAD);
hsecond = GlobalFree(LongToHandle(0xdeadbeef)); /* bogus handle */
ok( (hsecond == LongToHandle(0xdeadbeef)) && (GetLastError() == ERROR_INVALID_HANDLE),
"returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
hsecond, GetLastError(), LongToHandle(0xdeadbeef));
SetLastError(MAGIC_DEAD);
hsecond = GlobalFree(LongToHandle(0xdeadbee0)); /* bogus pointer */
ok( (hsecond == LongToHandle(0xdeadbee0)) &&
((GetLastError() == ERROR_INVALID_HANDLE) || broken(GetLastError() == ERROR_NOACCESS) /* wvista+ */),
"returned %p with 0x%08x (expected %p with ERROR_NOACCESS)\n",
hsecond, GetLastError(), LongToHandle(0xdeadbee0));
SetLastError(MAGIC_DEAD);
flags = GlobalFlags(gbl); flags = GlobalFlags(gbl);
ok( (flags == GMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE), ok( (flags == GMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE),
"returned 0x%04x with 0x%08x (expected GMEM_INVALID_HANDLE with " "returned 0x%04x with 0x%08x (expected GMEM_INVALID_HANDLE with "
...@@ -250,7 +262,7 @@ static void test_heap(void) ...@@ -250,7 +262,7 @@ static void test_heap(void)
ok(mem == NULL, "Expected NULL, got %p\n", mem); ok(mem == NULL, "Expected NULL, got %p\n", mem);
/* invalid free */ /* invalid free */
if (sizeof(void *) != 8) /* crashes on 64-bit Vista */ if (sizeof(void *) != 8) /* crashes on 64-bit */
{ {
SetLastError(MAGIC_DEAD); SetLastError(MAGIC_DEAD);
mem = GlobalFree(gbl); mem = GlobalFree(gbl);
......
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