kernel32: Change error return from GlobalFree.

Signed-off-by: Daniel Lehman <dlehman@esri.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Daniel Lehman 2018-01-30 12:18:02 -08:00 committed by Alexandre Julliard
parent f9181daa1d
commit fe09e2dba6
2 changed files with 16 additions and 4 deletions

View File

@ -784,8 +784,8 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
}
__EXCEPT_PAGE_FAULT
{
ERR("(%p): Page fault occurred ! Caused by bug ?\n", hmem);
SetLastError( ERROR_INVALID_PARAMETER );
ERR("invalid handle %p\n", hmem);
SetLastError(ERROR_INVALID_HANDLE);
hreturned = hmem;
}
__ENDTRY

View File

@ -217,6 +217,18 @@ static void test_heap(void)
"returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
hsecond, GetLastError(), gbl);
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);
ok( (flags == GMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE),
"returned 0x%04x with 0x%08x (expected GMEM_INVALID_HANDLE with "
@ -250,7 +262,7 @@ static void test_heap(void)
ok(mem == NULL, "Expected NULL, got %p\n", mem);
/* invalid free */
if (sizeof(void *) != 8) /* crashes on 64-bit Vista */
if (sizeof(void *) != 8) /* crashes on 64-bit */
{
SetLastError(MAGIC_DEAD);
mem = GlobalFree(gbl);