diff --git a/reactos/ntoskrnl/mm/ARM3/vadnode.c b/reactos/ntoskrnl/mm/ARM3/vadnode.c index a3aac247bea..0d6fbd6a47c 100644 --- a/reactos/ntoskrnl/mm/ARM3/vadnode.c +++ b/reactos/ntoskrnl/mm/ARM3/vadnode.c @@ -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)