Author: tfaber
Date: Sun May 8 08:12:09 2016
New Revision: 71281
URL:
http://svn.reactos.org/svn/reactos?rev=71281&view=rev
Log:
[0.4.1]
- Merge the heap user value fix from r71279/r71278
CORE-11196
Modified:
branches/ros-branch-0_4_1/reactos/ (props changed)
branches/ros-branch-0_4_1/reactos/sdk/lib/rtl/heap.c
branches/ros-branch-0_4_1/rostests/ (props changed)
branches/ros-branch-0_4_1/rostests/apitests/ntdll/RtlReAllocateHeap.c
Propchange: branches/ros-branch-0_4_1/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 8 08:12:09 2016
@@ -20,4 +20,4 @@
/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
/branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567
/branches/wlan-bringup:54809-54998
-/trunk/reactos:71217,71231-71232,71245,71252,71262
+/trunk/reactos:71217,71231-71232,71245,71252,71262,71279
Modified: branches/ros-branch-0_4_1/reactos/sdk/lib/rtl/heap.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_1/reactos/sdk/li…
==============================================================================
--- branches/ros-branch-0_4_1/reactos/sdk/lib/rtl/heap.c [iso-8859-1] (original)
+++ branches/ros-branch-0_4_1/reactos/sdk/lib/rtl/heap.c [iso-8859-1] Sun May 8 08:12:09
2016
@@ -2359,7 +2359,7 @@
}
/* Process extra stuff */
- if (RememberFlags & HEAP_ENTRY_EXTRA_PRESENT)
+ if (EntryFlags & HEAP_ENTRY_EXTRA_PRESENT)
{
/* Calculate pointers */
OldExtra = (PHEAP_ENTRY_EXTRA)(InUseEntry + InUseEntry->Size - 1);
Propchange: branches/ros-branch-0_4_1/rostests/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 8 08:12:09 2016
@@ -1,3 +1,3 @@
/branches/GSoC_2011/KMTestSuite:51165-53670
/branches/ros-amd64-bringup/rostests:44459,44462,44537
-/trunk/rostests:71232,71236
+/trunk/rostests:71232,71236,71278
Modified: branches/ros-branch-0_4_1/rostests/apitests/ntdll/RtlReAllocateHeap.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_1/rostests/apite…
==============================================================================
--- branches/ros-branch-0_4_1/rostests/apitests/ntdll/RtlReAllocateHeap.c [iso-8859-1]
(original)
+++ branches/ros-branch-0_4_1/rostests/apitests/ntdll/RtlReAllocateHeap.c [iso-8859-1] Sun
May 8 08:12:09 2016
@@ -69,6 +69,10 @@
SIZE_T OldSize = 0;
SIZE_T Size;
BOOLEAN Continue = TRUE;
+ BOOLEAN Success;
+ PVOID UserValue;
+ ULONG UserFlags;
+ PVOID Buffer2;
OldSize = 0x100;
Buffer = RtlReAllocateHeap(RtlGetProcessHeap(),
@@ -100,4 +104,88 @@
Continue = ReAllocBuffer(&Buffer, Size, &OldSize,
"shrinking");
}
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
+
+ /* Now make sure user flags/values get preserved */
+ OldSize = 0x100;
+ Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
+ HEAP_ZERO_MEMORY | HEAP_SETTABLE_USER_VALUE |
HEAP_SETTABLE_USER_FLAG2,
+ OldSize);
+ if (!Buffer)
+ {
+ skip("RtlAllocateHeap failed for size %lu\n", OldSize);
+ return;
+ }
+
+ UserValue = InvalidPointer;
+ UserFlags = 0x55555555;
+ Success = RtlGetUserInfoHeap(RtlGetProcessHeap(),
+ 0,
+ Buffer,
+ &UserValue,
+ &UserFlags);
+ ok(Success == TRUE, "RtlGetUserInfoHeap returned %u\n", Success);
+ ok(UserValue == NULL, "UserValue = %p\n", UserValue);
+ ok(UserFlags == HEAP_SETTABLE_USER_FLAG2, "UserFlags = %lx\n", UserFlags);
+
+ Success = RtlSetUserFlagsHeap(RtlGetProcessHeap(),
+ 0,
+ Buffer,
+ HEAP_SETTABLE_USER_FLAG1 | HEAP_SETTABLE_USER_FLAG2,
+ HEAP_SETTABLE_USER_FLAG3);
+ ok(Success == TRUE, "RtlSetUserFlagsHeap returned %u\n", Success);
+
+ Success = RtlSetUserValueHeap(RtlGetProcessHeap(),
+ 0,
+ Buffer,
+ &UserValue);
+ ok(Success == TRUE, "RtlSetUserValueHeap returned %u\n", Success);
+
+ UserValue = InvalidPointer;
+ UserFlags = 0x55555555;
+ Success = RtlGetUserInfoHeap(RtlGetProcessHeap(),
+ 0,
+ Buffer,
+ &UserValue,
+ &UserFlags);
+ ok(Success == TRUE, "RtlGetUserInfoHeap returned %u\n", Success);
+ ok(UserValue == &UserValue, "UserValue = %p, expected %p\n", UserValue,
&UserValue);
+ ok(UserFlags == HEAP_SETTABLE_USER_FLAG3, "UserFlags = %lx\n", UserFlags);
+
+ /* shrink (preserves flags) */
+ Buffer2 = RtlReAllocateHeap(RtlGetProcessHeap(),
+ HEAP_REALLOC_IN_PLACE_ONLY | HEAP_SETTABLE_USER_FLAG2,
+ Buffer,
+ OldSize / 2);
+ ok(Buffer2 == Buffer, "New Buffer is %p, expected %p\n", Buffer2, Buffer);
+ if (Buffer2) Buffer = Buffer2;
+ UserValue = InvalidPointer;
+ UserFlags = 0x55555555;
+ Success = RtlGetUserInfoHeap(RtlGetProcessHeap(),
+ 0,
+ Buffer,
+ &UserValue,
+ &UserFlags);
+ ok(Success == TRUE, "RtlGetUserInfoHeap returned %u\n", Success);
+ ok(UserValue == &UserValue, "UserValue = %p, expected %p\n", UserValue,
&UserValue);
+ ok(UserFlags == HEAP_SETTABLE_USER_FLAG3, "UserFlags = %lx\n", UserFlags);
+
+ /* grow (overwrites flags) */
+ Buffer2 = RtlReAllocateHeap(RtlGetProcessHeap(),
+ HEAP_REALLOC_IN_PLACE_ONLY | HEAP_SETTABLE_USER_FLAG1,
+ Buffer,
+ OldSize / 4 * 3);
+ ok(Buffer2 == Buffer, "New Buffer is %p, expected %p\n", Buffer2, Buffer);
+ if (Buffer2) Buffer = Buffer2;
+ UserValue = InvalidPointer;
+ UserFlags = 0x55555555;
+ Success = RtlGetUserInfoHeap(RtlGetProcessHeap(),
+ 0,
+ Buffer,
+ &UserValue,
+ &UserFlags);
+ ok(Success == TRUE, "RtlGetUserInfoHeap returned %u\n", Success);
+ ok(UserValue == &UserValue, "UserValue = %p, expected %p\n", UserValue,
&UserValue);
+ ok(UserFlags == HEAP_SETTABLE_USER_FLAG1, "UserFlags = %lx\n", UserFlags);
+
+ RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
}