Alexandre Julliard : ntdll: Fix the HEAP_CreateSubHeap return value ( spotted by Allan Tong).

Alexandre Julliard julliard at winehq.org
Wed Oct 3 06:08:14 CDT 2007


Module: wine
Branch: master
Commit: cbf8838dfb30ce80c0cc4734739a624da54ffe0b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cbf8838dfb30ce80c0cc4734739a624da54ffe0b

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Oct  3 10:08:34 2007 +0200

ntdll: Fix the HEAP_CreateSubHeap return value (spotted by Allan Tong).

---

 dlls/ntdll/heap.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 43d31c3..440939d 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -581,8 +581,8 @@ static void HEAP_ShrinkBlock(SUBHEAP *subheap, ARENA_INUSE *pArena, SIZE_T size)
 /***********************************************************************
  *           HEAP_InitSubHeap
  */
-static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
-                              SIZE_T commitSize, SIZE_T totalSize )
+static SUBHEAP *HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
+                                  SIZE_T commitSize, SIZE_T totalSize )
 {
     SUBHEAP *subheap;
     FREE_LIST_ENTRY *pEntry;
@@ -596,7 +596,7 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
                                  &commitSize, MEM_COMMIT, get_protection_type( flags ) ))
     {
         WARN("Could not commit %08lx bytes for sub-heap %p\n", commitSize, address );
-        return FALSE;
+        return NULL;
     }
 
     if (heap)
@@ -677,7 +677,7 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
     HEAP_CreateFreeBlock( subheap, (LPBYTE)subheap->base + subheap->headerSize,
                           subheap->size - subheap->headerSize );
 
-    return TRUE;
+    return subheap;
 }
 
 /***********************************************************************
@@ -690,6 +690,7 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, void *base, DWORD flags,
                                     SIZE_T commitSize, SIZE_T totalSize )
 {
     LPVOID address = base;
+    SUBHEAP *ret;
 
     /* round-up sizes on a 64K boundary */
     totalSize  = (totalSize + 0xffff) & 0xffff0000;
@@ -710,14 +711,12 @@ static SUBHEAP *HEAP_CreateSubHeap( HEAP *heap, void *base, DWORD flags,
 
     /* Initialize subheap */
 
-    if (!HEAP_InitSubHeap( heap, address, flags, commitSize, totalSize ))
+    if (!(ret = HEAP_InitSubHeap( heap, address, flags, commitSize, totalSize )))
     {
         SIZE_T size = 0;
         if (!base) NtFreeVirtualMemory( NtCurrentProcess(), &address, &size, MEM_RELEASE );
-        return NULL;
     }
-
-    return (SUBHEAP *)address;
+    return ret;
 }
 
 




More information about the wine-cvs mailing list