Fix the corner case when there is only "\0\0" appended and the Index is 1. Return missing string instead of empty string.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10914 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
niruiyu 2010-10-11 04:37:28 +00:00
parent f515069c19
commit d69bf66dc1
1 changed files with 5 additions and 1 deletions

View File

@ -677,7 +677,11 @@ GetOptionalStringByIndex (
StrSize = AsciiStrSize (OptionalStrStart);
} while (OptionalStrStart[StrSize] != 0 && Index != 0);
if (Index != 0) {
if ((Index != 0) || (StrSize == 1)) {
//
// Meet the end of strings set but Index is non-zero, or
// Find an empty string
//
*String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
} else {
*String = AllocatePool (StrSize * sizeof (CHAR16));