From 3db8e19d22f3ca499655997b328d866fcd1ad4ef Mon Sep 17 00:00:00 2001 From: Guy Albertelli Date: Sun, 14 Feb 1999 17:38:24 +0000 Subject: [PATCH] Fixed GlobalSize return value for zero size block. --- memory/global.c | 4 ++++ memory/heap.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/memory/global.c b/memory/global.c index b7ceebff96..c6a9f6aae7 100644 --- a/memory/global.c +++ b/memory/global.c @@ -1370,6 +1370,8 @@ DWORD WINAPI GlobalSize32( if(pintern->Magic==MAGIC_GLOBAL_USED) { + if (!pintern->Pointer) /* handle case of GlobalAlloc( ??,0) */ + return 0; retval=HeapSize(GetProcessHeap(), 0, (char *)(pintern->Pointer)-sizeof(HGLOBAL32))-4; } @@ -1380,6 +1382,8 @@ DWORD WINAPI GlobalSize32( } /* HeapUnlock(GetProcessHeap()); */ } + /* HeapSize returns 0xffffffff on failure */ + if (retval == 0xffffffff) retval = 0; return retval; } diff --git a/memory/heap.c b/memory/heap.c index 2e3f5800ea..2264fefb1b 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -1204,7 +1204,7 @@ BOOL32 WINAPI HeapUnlock( * HeapSize (KERNEL32.341) * RETURNS * Size in bytes of allocated memory - * 0: Failure + * 0xffffffff: Failure */ DWORD WINAPI HeapSize( HANDLE32 heap, /* [in] Handle of heap */