]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
Refine soma code to make code run safely.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Ui.c
index 0d3c1ebce8f3e7c88339e268ee6397c928b40645..d916aeb8cffa6e7e083a41a151155d31437b8d06 100644 (file)
@@ -2296,6 +2296,7 @@ UiDisplayMenu (
         //\r
         // Don't print anything if it is a NULL help token\r
         //\r
+        ASSERT(MenuOption != NULL);\r
         if (MenuOption->ThisTag->Help == 0) {\r
           StringPtr = L"\0";\r
         } else {\r
@@ -2372,6 +2373,16 @@ UiDisplayMenu (
       //\r
       case '+':\r
       case '-':\r
+        //\r
+        // If the screen has no menu items, and the user didn't select UiReset\r
+        // ignore the selection and go back to reading keys.\r
+        //\r
+        if(IsListEmpty (&gMenuOption)) {\r
+          ControlFlag = CfReadKey;\r
+          break;\r
+        }\r
+\r
+        ASSERT(MenuOption != NULL);\r
         Statement = MenuOption->ThisTag;\r
         if ((Statement->Operand == EFI_IFR_DATE_OP)\r
           || (Statement->Operand == EFI_IFR_TIME_OP)\r
@@ -2407,6 +2418,16 @@ UiDisplayMenu (
 \r
       case ' ':\r
         if ((gClassOfVfr & FORMSET_CLASS_FRONT_PAGE) != FORMSET_CLASS_FRONT_PAGE) {\r
+          //\r
+          // If the screen has no menu items, and the user didn't select UiReset\r
+          // ignore the selection and go back to reading keys.\r
+          //\r
+          if(IsListEmpty (&gMenuOption)) {\r
+            ControlFlag = CfReadKey;\r
+            break;\r
+          }\r
+          \r
+          ASSERT(MenuOption != NULL);\r
           if (MenuOption->ThisTag->Operand == EFI_IFR_CHECKBOX_OP && !MenuOption->GrayOut) {\r
             ScreenOperation = UiSelect;\r
           }\r
@@ -2478,6 +2499,7 @@ UiDisplayMenu (
     case CfUiSelect:\r
       ControlFlag = CfCheckSelection;\r
 \r
+      ASSERT(MenuOption != NULL);\r
       Statement = MenuOption->ThisTag;\r
       if ((Statement->Operand == EFI_IFR_TEXT_OP) ||\r
           (Statement->Operand == EFI_IFR_DATE_OP) ||\r
@@ -2744,11 +2766,13 @@ UiDisplayMenu (
 \r
     case CfUiLeft:\r
       ControlFlag = CfCheckSelection;\r
+      ASSERT(MenuOption != NULL);\r
       if ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) {\r
         if (MenuOption->Sequence != 0) {\r
           //\r
           // In the middle or tail of the Date/Time op-code set, go left.\r
           //\r
+          ASSERT(NewPos != NULL);\r
           NewPos = NewPos->BackLink;\r
         }\r
       }\r
@@ -2756,11 +2780,13 @@ UiDisplayMenu (
 \r
     case CfUiRight:\r
       ControlFlag = CfCheckSelection;\r
+      ASSERT(MenuOption != NULL);\r
       if ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) {\r
         if (MenuOption->Sequence != 2) {\r
           //\r
           // In the middle or tail of the Date/Time op-code set, go left.\r
           //\r
+          ASSERT(NewPos != NULL);\r
           NewPos = NewPos->ForwardLink;\r
         }\r
       }\r
@@ -2771,6 +2797,7 @@ UiDisplayMenu (
 \r
       SavedListEntry = TopOfScreen;\r
 \r
+      ASSERT(NewPos != NULL);\r
       if (NewPos->BackLink != &gMenuOption) {\r
         NewLine = TRUE;\r
         //\r
@@ -2800,6 +2827,7 @@ UiDisplayMenu (
         // Check the previous menu entry to see if it was a zero-length advance.  If it was,\r
         // don't worry about a redraw.\r
         //\r
+        ASSERT(MenuOption != NULL);\r
         if ((INTN) MenuOption->Row - (INTN) DistanceValue < (INTN) TopRow) {\r
           Repaint     = TRUE;\r
           TopOfScreen = NewPos;\r
@@ -2857,6 +2885,7 @@ UiDisplayMenu (
     case CfUiPageUp:\r
       ControlFlag     = CfCheckSelection;\r
 \r
+      ASSERT(NewPos != NULL);\r
       if (NewPos->BackLink == &gMenuOption) {\r
         NewLine = FALSE;\r
         Repaint = FALSE;\r
@@ -3115,6 +3144,7 @@ UiDisplayMenu (
       Status = SubmitForm (Selection->FormSet, Selection->Form);\r
 \r
       if (!EFI_ERROR (Status)) {\r
+        ASSERT(MenuOption != NULL);\r
         UpdateStatusBar (INPUT_ERROR, MenuOption->ThisTag->QuestionFlags, FALSE);\r
         UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->QuestionFlags, FALSE);\r
       } else {\r