Rémi Bernon : ntdll: Create free block after updating the size in HEAP_ShrinkBlock.

Alexandre Julliard julliard at winehq.org
Wed May 18 15:38:30 CDT 2022


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Wed May 18 09:42:28 2022 +0200

ntdll: Create free block after updating the size in HEAP_ShrinkBlock.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/heap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index eb45a94da95..3a1a4268683 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -815,17 +815,17 @@ static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena )
  */
 static void HEAP_ShrinkBlock(SUBHEAP *subheap, ARENA_INUSE *pArena, SIZE_T size)
 {
-    if ((pArena->size & ARENA_SIZE_MASK) >= size + HEAP_MIN_SHRINK_SIZE)
+    SIZE_T old_data_size = pArena->size & ARENA_SIZE_MASK;
+    if (old_data_size >= size + HEAP_MIN_SHRINK_SIZE)
     {
-        HEAP_CreateFreeBlock( subheap, (char *)(pArena + 1) + size,
-                              (pArena->size & ARENA_SIZE_MASK) - size );
 	/* assign size plus previous arena flags */
         pArena->size = size | (pArena->size & ~ARENA_SIZE_MASK);
+        HEAP_CreateFreeBlock( subheap, (char *)(pArena + 1) + size, old_data_size - size );
     }
     else
     {
         /* Turn off PREV_FREE flag in next block */
-        char *pNext = (char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK);
+        char *pNext = (char *)(pArena + 1) + old_data_size;
         if (pNext < (char *)subheap->base + subheap->size)
             *(DWORD *)pNext &= ~ARENA_FLAG_PREV_FREE;
     }




More information about the wine-cvs mailing list