- Fix the stupid mess we created when making this from the cmake branch
[reactos.git] / ntoskrnl / mm / ARM3 / vadnode.c
index a3aac24..0d6fbd6 100644 (file)
@@ -393,10 +393,11 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length,
     /* Calculate the initial upper margin */
     HighVpn = BoundaryAddress >> PAGE_SHIFT;
 
-    /* Starting from the root, go down until the right-most child,
-       trying to stay below the boundary. */
+    /* Starting from the root, go down until the right-most child
+        * which is just behind the boundary*/
     LowestNode = Node = RtlRightChildAvl(&Table->BalancedRoot);
-    while ((Child = RtlRightChildAvl(Node))) Node = Child;
+    while (((Child = RtlRightChildAvl(Node)) != 0 )
+                       && (Node->EndingVpn < HighVpn )) Node = Child;
 
     /* Now loop the Vad nodes */
     while (Node)