[CMAKE]
[reactos.git] / ntoskrnl / mm / marea.c
index 2c75674..cacf2ae 100644 (file)
@@ -374,8 +374,9 @@ MmInsertMemoryArea(
    /* Build a lame VAD if this is a user-space allocation */
    if ((marea->EndingAddress < MmSystemRangeStart) && (marea->Type != MEMORY_AREA_OWNED_BY_ARM3))
    {
-       ASSERT(marea->Type == MEMORY_AREA_VIRTUAL_MEMORY || marea->Type == MEMORY_AREA_SECTION_VIEW);
        PMMVAD Vad;
+
+       ASSERT(marea->Type == MEMORY_AREA_VIRTUAL_MEMORY || marea->Type == MEMORY_AREA_SECTION_VIEW);
        Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD), 'Fake');
        ASSERT(Vad);
        RtlZeroMemory(Vad, sizeof(MMVAD));
@@ -492,13 +493,16 @@ MmFindGapBottomUp(
          break;
 
       AlignedAddress = MM_ROUND_UP(PreviousNode->EndingAddress, Granularity);
-      if (Node->StartingAddress > AlignedAddress &&
-          (ULONG_PTR)Node->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
+      if (AlignedAddress >= LowestAddress)
       {
-         DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
-         return AlignedAddress;
+          if (Node->StartingAddress > AlignedAddress &&
+              (ULONG_PTR)Node->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
+          {
+             DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
+             ASSERT(AlignedAddress >= LowestAddress);
+             return AlignedAddress;
+          }
       }
-
       PreviousNode = Node;
    }
 
@@ -508,6 +512,7 @@ MmFindGapBottomUp(
        (ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length)
    {
       DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
+      ASSERT(AlignedAddress >= LowestAddress);
       return AlignedAddress;
    }
 
@@ -517,6 +522,7 @@ MmFindGapBottomUp(
        (ULONG_PTR)FirstNode->StartingAddress - (ULONG_PTR)AlignedAddress >= Length)
    {
       DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress);
+      ASSERT(AlignedAddress >= LowestAddress);
       return AlignedAddress;
    }