From 436b7ddf1ee386c2b7a62585f06d4d54d9c11932 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Tue, 12 Dec 2023 14:32:51 -0500 Subject: [PATCH] MsGraphicsPkg/SimpleUIToolKit: Move array bounds check before access Checks the index is within expected bounds before accessing the array. Signed-off-by: Michael Kubacki --- MsGraphicsPkg/Library/SimpleUIToolKit/ListBox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MsGraphicsPkg/Library/SimpleUIToolKit/ListBox.c b/MsGraphicsPkg/Library/SimpleUIToolKit/ListBox.c index cbd8c23aea..249810a221 100644 --- a/MsGraphicsPkg/Library/SimpleUIToolKit/ListBox.c +++ b/MsGraphicsPkg/Library/SimpleUIToolKit/ListBox.c @@ -946,7 +946,7 @@ Ctor ( // Iterate through cell list and compute bounding rectangle, checkbox bounding rectangle (optional) and string bitmap rectangle. // - for (Index = 0; CellData[Index].CellText != NULL && Index < this->m_NumberOfCells; Index++) { + for (Index = 0; Index < this->m_NumberOfCells && CellData[Index].CellText != NULL; Index++) { this->m_pCells[Index].OriginalOrder = Index; this->m_pCells[Index].pCellText = AllocateCopyPool (StrSize (CellData[Index].CellText), CellData[Index].CellText); this->m_pCells[Index].CheckboxSelected = CellData[Index].CheckBoxSelected;