UefiCpuPkg/MtrrLib: Fix unit test read overflow

Change conditional check to check the array index before
reading the array member to prevent read past end of buffer.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Michael D Kinney 2024-10-23 18:47:22 -07:00 committed by mergify[bot]
parent fadf4f377e
commit 171335e34e

View File

@ -745,7 +745,7 @@ GetNextDifferentElementInSortedArray (
UINT64 CurrentElement;
CurrentElement = Array[Index];
while (CurrentElement == Array[Index] && Index < Count) {
while ((Index < Count) && (CurrentElement == Array[Index])) {
Index++;
}