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

commit c66b66656bde3d35028aefe64e8900482ee65af5
Author: Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Wed Oct 11 18:35:54 2017 +0200

    [NTOSKRNL] Add ASSERTs to make sure, we never use an uninitialized variable
---
 ntoskrnl/mm/ARM3/vadnode.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/vadnode.c b/ntoskrnl/mm/ARM3/vadnode.c
index 4ada3ad6c0..b20839ab62 100644
--- a/ntoskrnl/mm/ARM3/vadnode.c
+++ b/ntoskrnl/mm/ARM3/vadnode.c
@@ -601,7 +601,7 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length,
                                 OUT PULONG_PTR Base,
                                 OUT PMMADDRESS_NODE *Parent)
 {
-    PMMADDRESS_NODE Node, OldNode, Child;
+    PMMADDRESS_NODE Node, OldNode = NULL, Child;
     ULONG_PTR LowVpn, HighVpn, AlignmentVpn;
     PFN_NUMBER PageCount;
 
@@ -670,8 +670,14 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length,
             }
             else
             {
-                /* Node has a right child, the node we had before is the most
-                   left grandchild of that right child, use it as parent. */
+                /* Node has a right child. This means we must have already
+                   moved one node left from the right-most node we started
+                   with, thus we already have an OldNode! */
+                ASSERT(OldNode != NULL);
+
+                /* The node we had before is the most left grandchild of 
+                   that right child, use it as parent. */
+                ASSERT(RtlLeftChildAvl(OldNode) == NULL);
                 *Parent = OldNode;
                 return TableInsertAsLeft;
             }

Reply via email to