public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] MdeMoudlePkg/DisplayEngine: Fix incorrect index used in array "InputText"
@ 2017-02-10  2:25 Dandan Bi
  2017-02-17  1:20 ` Bi, Dandan
  2017-02-20 11:11 ` Dong, Eric
  0 siblings, 2 replies; 3+ messages in thread
From: Dandan Bi @ 2017-02-10  2:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao, Wang Cloud

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>
---
 .../Universal/DisplayEngineDxe/InputHandler.c      | 33 ++++++++++++----------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
index 400b934..d02c0bf 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c
@@ -1,9 +1,9 @@
 /** @file
 Implementation for handling user input from the User Interfaces.
 
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
@@ -522,10 +522,11 @@ GetNumericInput (
   Negative          = FALSE;
   ValidateFail      = FALSE;
 
   Question      = MenuOption->ThisTag;
   QuestionValue = &Question->CurrentValue;
+  ZeroMem (InputText, MAX_NUMERIC_INPUT_WIDTH * sizeof (CHAR16));
 
   //
   // Only two case, user can enter to this function: Enter and +/- case.
   // In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT
   //
@@ -688,20 +689,21 @@ GetNumericInput (
       }
 
       if (MenuOption->Sequence == 0) {
         InputText[0] = LEFT_NUMERIC_DELIMITER;
         SetUnicodeMem (InputText + 1, InputWidth, L' ');
-      } else {
+        InputText[InputWidth + 1] = DATE_SEPARATOR;
+        InputText[InputWidth + 2] = L'\0';
+      } else  if (MenuOption->Sequence == 1){
         SetUnicodeMem (InputText, InputWidth, L' ');
-      }
-
-      if (MenuOption->Sequence == 2) {
-        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
+        InputText[InputWidth] = DATE_SEPARATOR;
+        InputText[InputWidth + 1] = L'\0';
       } else {
-        InputText[InputWidth + 1] = DATE_SEPARATOR;
+        SetUnicodeMem (InputText, InputWidth, L' ');
+        InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;
+        InputText[InputWidth + 1] = L'\0';
       }
-      InputText[InputWidth + 2] = L'\0';
 
       PrintStringAt (Column, Row, InputText);
       if (MenuOption->Sequence == 0) {
         Column++;
       }
@@ -711,20 +713,21 @@ GetNumericInput (
       InputWidth = 2;
 
       if (MenuOption->Sequence == 0) {
         InputText[0] = LEFT_NUMERIC_DELIMITER;
         SetUnicodeMem (InputText + 1, InputWidth, L' ');
-      } else {
+        InputText[InputWidth + 1] = TIME_SEPARATOR;
+        InputText[InputWidth + 2] = L'\0';
+      } else if (MenuOption->Sequence == 1){
         SetUnicodeMem (InputText, InputWidth, L' ');
-      }
-
-      if (MenuOption->Sequence == 2) {
-        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
+        InputText[InputWidth] = TIME_SEPARATOR;
+        InputText[InputWidth + 1] = L'\0';
       } else {
-        InputText[InputWidth + 1] = TIME_SEPARATOR;
+        SetUnicodeMem (InputText, InputWidth, L' ');
+        InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;
+        InputText[InputWidth + 1] = L'\0';
       }
-      InputText[InputWidth + 2] = L'\0';
 
       PrintStringAt (Column, Row, InputText);
       if (MenuOption->Sequence == 0) {
         Column++;
       }
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-20 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-10  2:25 [patch] MdeMoudlePkg/DisplayEngine: Fix incorrect index used in array "InputText" Dandan Bi
2017-02-17  1:20 ` Bi, Dandan
2017-02-20 11:11 ` Dong, Eric

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox