kernel32: Fix some 64-bit issues in GlobalSize().

This commit is contained in:
Alexandre Julliard 2011-06-13 11:40:53 +02:00
parent fed025fd42
commit 4b12e9c5a0
1 changed files with 7 additions and 9 deletions

View File

@ -808,7 +808,7 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
*/ */
SIZE_T WINAPI GlobalSize(HGLOBAL hmem) SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
{ {
DWORD retval; SIZE_T retval;
PGLOBAL32_INTERN pintern; PGLOBAL32_INTERN pintern;
if (!((ULONG_PTR)hmem >> 16)) if (!((ULONG_PTR)hmem >> 16))
@ -821,10 +821,10 @@ SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
{ {
retval=HeapSize(GetProcessHeap(), 0, hmem); retval=HeapSize(GetProcessHeap(), 0, hmem);
if (retval == (DWORD)-1) /* It might be a GMEM_MOVEABLE data pointer */ if (retval == ~0ul) /* It might be a GMEM_MOVEABLE data pointer */
{ {
retval = HeapSize(GetProcessHeap(), 0, (char*)(hmem) - HGLOBAL_STORAGE); retval = HeapSize(GetProcessHeap(), 0, (char*)hmem - HGLOBAL_STORAGE);
if (retval != (DWORD)-1) retval -= HGLOBAL_STORAGE; if (retval != ~0ul) retval -= HGLOBAL_STORAGE;
} }
} }
else else
@ -838,9 +838,8 @@ SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
retval = 0; retval = 0;
else else
{ {
retval = HeapSize(GetProcessHeap(), 0, retval = HeapSize(GetProcessHeap(), 0, (char *)pintern->Pointer - HGLOBAL_STORAGE );
(char *)(pintern->Pointer) - HGLOBAL_STORAGE ); if (retval != ~0ul) retval -= HGLOBAL_STORAGE;
if (retval != (DWORD)-1) retval -= HGLOBAL_STORAGE;
} }
} }
else else
@ -851,8 +850,7 @@ SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
} }
RtlUnlockHeap(GetProcessHeap()); RtlUnlockHeap(GetProcessHeap());
} }
/* HeapSize returns 0xffffffff on failure */ if (retval == ~0ul) retval = 0;
if (retval == 0xffffffff) retval = 0;
return retval; return retval;
} }