return NULL;\r
}\r
//\r
+ // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
+ //\r
+ ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment)));\r
+ //\r
// We would rather waste some memory to save PEI code size.\r
//\r
Memory = InternalAllocatePages (MemoryType, Pages + EFI_SIZE_TO_PAGES (Alignment));\r
} else {\r
AlignmentMask = Alignment - 1;\r
}\r
+ //\r
+ // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
+ //\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
\r
RawAddress = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask);\r
\r
AlignmentMask = Alignment - 1;\r
}\r
\r
+ //\r
+ // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
+ //\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
+\r
RawAddress = AllocatePool (AllocationSize + AlignmentMask);\r
\r
AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;\r