Skip to content

Commit

Permalink
MsGraphicsPkg/SimpleUIToolKit: Move array bounds check before access
Browse files Browse the repository at this point in the history
Checks the index is within expected bounds before accessing the array.

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki committed Dec 12, 2023
1 parent c67a13e commit ddd16f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion MsGraphicsPkg/Library/SimpleUIToolKit/ListBox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ddd16f0

Please sign in to comment.