From c21ade114a7b22d87a28a0778ab22941e8ca4d55 Mon Sep 17 00:00:00 2001 From: Mark Tempel Date: Tue, 14 Oct 2003 01:44:39 +0000 Subject: [PATCH] Update to correct a bug in GlobalSize with GMEM_MOVEABLE memory. Now a valid heap pointer is passed into RtlSizeHeap. svn path=/trunk/; revision=6308 --- reactos/lib/kernel32/mem/global.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/reactos/lib/kernel32/mem/global.c b/reactos/lib/kernel32/mem/global.c index 3c5c32e5d0c..4275ca24adf 100644 --- a/reactos/lib/kernel32/mem/global.c +++ b/reactos/lib/kernel32/mem/global.c @@ -1,4 +1,4 @@ -/* $Id: global.c,v 1.14 2003/10/13 04:45:30 mtempel Exp $ +/* $Id: global.c,v 1.15 2003/10/14 01:44:39 mtempel Exp $ * * Win32 Global/Local heap functions (GlobalXXX, LocalXXX). * These functions included in Win32 for compatibility with 16 bit Windows @@ -516,7 +516,7 @@ GlobalReAlloc(HGLOBAL hMem, DWORD STDCALL GlobalSize(HGLOBAL hMem) { - DWORD retval = 0; + SIZE_T retval = 0; PGLOBAL_HANDLE phandle = 0; DbgPrint("GlobalSize( 0x%lX )\n", (ULONG)hMem); @@ -535,7 +535,22 @@ GlobalSize(HGLOBAL hMem) { if (0 != phandle->Pointer)/*NOT DISCARDED*/ { - retval = RtlSizeHeap(GetProcessHeap(), 0, phandle->Pointer) - HANDLE_SIZE; + retval = RtlSizeHeap(GetProcessHeap(), 0, phandle->Pointer - HANDLE_SIZE); + + if (retval == (SIZE_T)-1) /*RtlSizeHeap failed*/ + { + /* + **TODO: RtlSizeHeap does not set last error. + ** We should choose an error value to set as + ** the last error. Which One? + */ + DbgPrint("GlobalSize: RtlSizeHeap failed.\n"); + retval = 0; + } + else /*Everything is ok*/ + { + retval = retval - HANDLE_SIZE; + } } } else