1) Replace immediate constant with MACRO.
2) Add in ASSERT for NULL before dereferencing pointers and after memory allocation.
3) Add a return statement in ProcessOptions to handle the mismatch between the value stored and the opcode for one-of-option in orderedlist opcode. This case occurs when the one-of-optoin entry in OrderedList get deleted.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7320
6f19259b-4bc3-4df7-8a09-
765794883524
EFI_STATUS Status;\r
UINTN Column;\r
UINTN Row;\r
- CHAR16 InputText[23];\r
- CHAR16 FormattedNumber[22];\r
- UINT64 PreviousNumber[20];\r
+ CHAR16 InputText[MAX_NUMERIC_INPUT_WIDTH];\r
+ CHAR16 FormattedNumber[MAX_NUMERIC_INPUT_WIDTH - 1];\r
+ UINT64 PreviousNumber[MAX_NUMERIC_INPUT_WIDTH - 3];\r
UINTN Count;\r
UINTN Loop;\r
BOOLEAN ManualInput;\r
\r
InputText[0] = LEFT_NUMERIC_DELIMITER;\r
SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+ ASSERT (InputWidth < MAX_NUMERIC_INPUT_WIDTH); \r
InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
InputText[InputWidth + 2] = L'\0';\r
\r
\r
if (EditValue > Maximum) {\r
UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE);\r
+ ASSERT (Count < sizeof (PreviousNumber) / sizeof (PreviousNumber[0]));\r
EditValue = PreviousNumber[Count];\r
break;\r
} else {\r
if (HighlightOptionIndex > 0) {\r
HighlightOptionIndex--;\r
\r
+ ASSERT (CurrentOption != NULL);\r
SwapListEntries (CurrentOption->Link.BackLink, &CurrentOption->Link);\r
}\r
}\r
if (HighlightOptionIndex < (PopUpMenuLines - 1)) {\r
HighlightOptionIndex++;\r
\r
+ ASSERT (CurrentOption != NULL);\r
SwapListEntries (&CurrentOption->Link, CurrentOption->Link.ForwardLink);\r
}\r
}\r
Link = GetNextNode (&Question->OptionListHead, Link);\r
}\r
} else {\r
+ ASSERT (CurrentOption != NULL);\r
CopyMem (&Question->HiiValue, &CurrentOption->Value, sizeof (EFI_HII_VALUE));\r
}\r
\r
CHAR16 *StrFrontPageBanner;\r
UINTN Row;\r
EFI_SCREEN_DESCRIPTOR LocalScreen;\r
+ UINTN RowIdx;\r
+ UINTN ColumnIdx;\r
\r
ZeroMem (&LocalScreen, sizeof (EFI_SCREEN_DESCRIPTOR));\r
gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &LocalScreen.RightColumn, &LocalScreen.BottomRow);\r
Alignment < BANNER_COLUMNS + (UINT8) LocalScreen.LeftColumn;\r
Alignment++\r
) {\r
- if (BannerData->Banner[Line - (UINT8) LocalScreen.TopRow][Alignment - (UINT8) LocalScreen.LeftColumn] != 0x0000) {\r
+ RowIdx = Line - (UINT8) LocalScreen.TopRow;\r
+ ColumnIdx = Alignment - (UINT8) LocalScreen.LeftColumn;\r
+\r
+ ASSERT (RowIdx < BANNER_HEIGHT);\r
+ ASSERT (ColumnIdx < BANNER_COLUMNS);\r
+ \r
+ if (BannerData->Banner[RowIdx][ColumnIdx] != 0x0000) {\r
StrFrontPageBanner = GetToken (\r
- BannerData->Banner[Line - (UINT8) LocalScreen.TopRow][Alignment - (UINT8) LocalScreen.LeftColumn],\r
+ BannerData->Banner[RowIdx][ColumnIdx],\r
FrontPageHandle\r
);\r
} else {\r
\r
FreePool (*OptionString);\r
*OptionString = NULL;\r
+ return EFI_NOT_FOUND;\r
}\r
\r
if ((OneOfOption->SuppressExpression != NULL) &&\r
}\r
\r
TempString = AllocateCopyPool ((Maximum + 1) * sizeof (CHAR16), Question->BufferValue);\r
+ ASSERT (TempString != NULL);\r
+ \r
TempString[Maximum] = L'\0';\r
\r
if (StrCmp (StringPtr, TempString) != 0) {\r
//\r
AllocateSize = 0x20;\r
IndexArray = AllocatePool (AllocateSize * sizeof (UINTN) * 3);\r
+ ASSERT (IndexArray != NULL);\r
\r
if (*FormattedString != NULL) {\r
FreePool (*FormattedString);\r
\r
VirtualLineCount = RowCount * (LineCount / RowCount + (LineCount % RowCount > 0));\r
*FormattedString = AllocateZeroPool (VirtualLineCount * (BlockWidth + 1) * sizeof (CHAR16) * 2);\r
+ ASSERT (*FormattedString != NULL);\r
\r
for (CurrIndex = 0; CurrIndex < LineCount; CurrIndex ++) {\r
*(*FormattedString + CurrIndex * 2 * (BlockWidth + 1)) = (CHAR16) ((IndexArray[CurrIndex*3+2] == 2) ? WIDE_CHAR : NARROW_CHAR);\r
\r
#define SUBTITLE_INDENT 2\r
\r
+\r
+//\r
+// It take 23 characters including the NULL to print a 64 bits number with "[" and "]".\r
+// pow(2, 64) = [18446744073709551616]\r
+//\r
+#define MAX_NUMERIC_INPUT_WIDTH 23\r
+\r
typedef enum {\r
UiNoOperation,\r
UiDefault,\r