/* 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)