https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6d697561f0ae70875858c808f14c20ab2602f6d5

commit 6d697561f0ae70875858c808f14c20ab2602f6d5
Author:     Jérôme Gardou <jerome.gar...@reactos.org>
AuthorDate: Thu Jan 28 18:42:59 2021 +0100
Commit:     Jérôme Gardou <jerome.gar...@reactos.org>
CommitDate: Fri Jan 29 09:42:13 2021 +0100

    [RTL] Fix heap usage flags
    
     - Use Heap->ForceFlags where needed
     - Use passed-in flags instead of the heap flags in some places
     - Do not recursively acquire the heap lock
---
 sdk/lib/rtl/heap.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/sdk/lib/rtl/heap.c b/sdk/lib/rtl/heap.c
index a75c18f5d2a..2eba86e046e 100644
--- a/sdk/lib/rtl/heap.c
+++ b/sdk/lib/rtl/heap.c
@@ -2681,7 +2681,8 @@ RtlReAllocateHeap(HANDLE HeapPtr,
     {
         RtlEnterHeapLock(Heap->LockVariable, TRUE);
         HeapLocked = TRUE;
-        Flags &= ~HEAP_NO_SERIALIZE;
+        /* Do not acquire the lock anymore for re-entrant call */
+        Flags |= HEAP_NO_SERIALIZE;
     }
 
     /* Get the pointer to the in-use entry */
@@ -3656,7 +3657,7 @@ BOOLEAN NTAPI RtlValidateHeap(
     }
 
     /* Force flags */
-    Flags = Heap->ForceFlags;
+    Flags |= Heap->ForceFlags;
 
     /* Acquire the lock if necessary */
     if (!(Flags & HEAP_NO_SERIALIZE))
@@ -3744,7 +3745,7 @@ RtlSetUserValueHeap(IN PVOID HeapHandle,
     BOOLEAN HeapLocked = FALSE, ValueSet = FALSE;
 
     /* Force flags */
-    Flags |= Heap->Flags;
+    Flags |= Heap->ForceFlags;
 
     /* Call special heap */
     if (RtlpHeapIsSpecial(Flags))
@@ -3806,14 +3807,14 @@ RtlSetUserFlagsHeap(IN PVOID HeapHandle,
     BOOLEAN HeapLocked = FALSE;
 
     /* Force flags */
-    Flags |= Heap->Flags;
+    Flags |= Heap->ForceFlags;
 
     /* Call special heap */
     if (RtlpHeapIsSpecial(Flags))
         return RtlDebugSetUserFlagsHeap(Heap, Flags, BaseAddress, 
UserFlagsReset, UserFlagsSet);
 
     /* Lock if it's lockable */
-    if (!(Heap->Flags & HEAP_NO_SERIALIZE))
+    if (!(Flags & HEAP_NO_SERIALIZE))
     {
         RtlEnterHeapLock(Heap->LockVariable, TRUE);
         HeapLocked = TRUE;
@@ -3862,14 +3863,14 @@ RtlGetUserInfoHeap(IN PVOID HeapHandle,
     BOOLEAN HeapLocked = FALSE;
 
     /* Force flags */
-    Flags |= Heap->Flags;
+    Flags |= Heap->ForceFlags;
 
     /* Call special heap */
     if (RtlpHeapIsSpecial(Flags))
         return RtlDebugGetUserInfoHeap(Heap, Flags, BaseAddress, UserValue, 
UserFlags);
 
     /* Lock if it's lockable */
-    if (!(Heap->Flags & HEAP_NO_SERIALIZE))
+    if (!(Flags & HEAP_NO_SERIALIZE))
     {
         RtlEnterHeapLock(Heap->LockVariable, TRUE);
         HeapLocked = TRUE;

Reply via email to