]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeMoudlePkg/DisplayEngine: Fix incorrect index used in array "InputText"
authorDandan Bi <dandan.bi@intel.com>
Thu, 9 Feb 2017 13:17:34 +0000 (21:17 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 21 Feb 2017 11:19:05 +0000 (19:19 +0800)
When set value to the array "InputText", the index was used incorrectly.
And the array "InputText" is not initialized. These will cause some value
in the array is random, so it will be shown incorrectly sometimes.
This patch is to fix this issue.

https://bugzilla.tianocore.org/show_bug.cgi?id=358

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Wang Cloud <winggundum82@163.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c

index 400b93427caa162e0310605da3766764082a228e..d02c0bf0742433ef5f0ba2187dad22a410539848 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation for handling user input from the User Interfaces.\r
 \r
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -524,6 +524,7 @@ GetNumericInput (
 \r
   Question      = MenuOption->ThisTag;\r
   QuestionValue = &Question->CurrentValue;\r
+  ZeroMem (InputText, MAX_NUMERIC_INPUT_WIDTH * sizeof (CHAR16));\r
 \r
   //\r
   // Only two case, user can enter to this function: Enter and +/- case.\r
@@ -690,16 +691,17 @@ GetNumericInput (
       if (MenuOption->Sequence == 0) {\r
         InputText[0] = LEFT_NUMERIC_DELIMITER;\r
         SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
-      } else {\r
+        InputText[InputWidth + 1] = DATE_SEPARATOR;\r
+        InputText[InputWidth + 2] = L'\0';\r
+      } else  if (MenuOption->Sequence == 1){\r
         SetUnicodeMem (InputText, InputWidth, L' ');\r
-      }\r
-\r
-      if (MenuOption->Sequence == 2) {\r
-        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth] = DATE_SEPARATOR;\r
+        InputText[InputWidth + 1] = L'\0';\r
       } else {\r
-        InputText[InputWidth + 1] = DATE_SEPARATOR;\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+        InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth + 1] = L'\0';\r
       }\r
-      InputText[InputWidth + 2] = L'\0';\r
 \r
       PrintStringAt (Column, Row, InputText);\r
       if (MenuOption->Sequence == 0) {\r
@@ -713,16 +715,17 @@ GetNumericInput (
       if (MenuOption->Sequence == 0) {\r
         InputText[0] = LEFT_NUMERIC_DELIMITER;\r
         SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
-      } else {\r
+        InputText[InputWidth + 1] = TIME_SEPARATOR;\r
+        InputText[InputWidth + 2] = L'\0';\r
+      } else if (MenuOption->Sequence == 1){\r
         SetUnicodeMem (InputText, InputWidth, L' ');\r
-      }\r
-\r
-      if (MenuOption->Sequence == 2) {\r
-        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth] = TIME_SEPARATOR;\r
+        InputText[InputWidth + 1] = L'\0';\r
       } else {\r
-        InputText[InputWidth + 1] = TIME_SEPARATOR;\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+        InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;\r
+        InputText[InputWidth + 1] = L'\0';\r
       }\r
-      InputText[InputWidth + 2] = L'\0';\r
 \r
       PrintStringAt (Column, Row, InputText);\r
       if (MenuOption->Sequence == 0) {\r