summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Dxe/Mem/HeapGuard.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
index 19245049c2..ac043b5d9b 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -225,8 +225,8 @@ FindGuardedMemoryMap (
//
// Adjust current map table depth according to the address to access
//
- while (mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH
- &&
+ while (AllocMapUnit &&
+ mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH &&
RShiftU64 (
Address,
mLevelShift[GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel - 1]
@@ -904,6 +904,10 @@ AdjustMemoryS (
}
Target = Start + Size - SizeRequested;
+ ASSERT (Target >= Start);
+ if (Target == 0) {
+ return 0;
+ }
if (!IsGuardPage (Start + Size)) {
// No Guard at tail to share. One more page is needed.