MdeMoudlePkg/DisplayEngine: Fix incorrect index used in array "InputText"

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>
This commit is contained in:
Dandan Bi 2017-02-09 21:17:34 +08:00 committed by Hao Wu
parent 087132a84a
commit 5c793e7703

@ -1,7 +1,7 @@
/** @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
@ -524,6 +524,7 @@ GetNumericInput (
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.
@ -690,17 +691,18 @@ GetNumericInput (
if (MenuOption->Sequence == 0) {
InputText[0] = LEFT_NUMERIC_DELIMITER;
SetUnicodeMem (InputText + 1, InputWidth, L' ');
InputText[InputWidth + 1] = DATE_SEPARATOR;
InputText[InputWidth + 2] = L'\0';
} else if (MenuOption->Sequence == 1){
SetUnicodeMem (InputText, InputWidth, L' ');
InputText[InputWidth] = DATE_SEPARATOR;
InputText[InputWidth + 1] = L'\0';
} else {
SetUnicodeMem (InputText, InputWidth, L' ');
InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;
InputText[InputWidth + 1] = L'\0';
}
if (MenuOption->Sequence == 2) {
InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
} else {
InputText[InputWidth + 1] = DATE_SEPARATOR;
}
InputText[InputWidth + 2] = L'\0';
PrintStringAt (Column, Row, InputText);
if (MenuOption->Sequence == 0) {
Column++;
@ -713,17 +715,18 @@ GetNumericInput (
if (MenuOption->Sequence == 0) {
InputText[0] = LEFT_NUMERIC_DELIMITER;
SetUnicodeMem (InputText + 1, InputWidth, L' ');
InputText[InputWidth + 1] = TIME_SEPARATOR;
InputText[InputWidth + 2] = L'\0';
} else if (MenuOption->Sequence == 1){
SetUnicodeMem (InputText, InputWidth, L' ');
InputText[InputWidth] = TIME_SEPARATOR;
InputText[InputWidth + 1] = L'\0';
} else {
SetUnicodeMem (InputText, InputWidth, L' ');
InputText[InputWidth] = RIGHT_NUMERIC_DELIMITER;
InputText[InputWidth + 1] = L'\0';
}
if (MenuOption->Sequence == 2) {
InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;
} else {
InputText[InputWidth + 1] = TIME_SEPARATOR;
}
InputText[InputWidth + 2] = L'\0';
PrintStringAt (Column, Row, InputText);
if (MenuOption->Sequence == 0) {
Column++;