Enhance HiiThunkGetString to handle the case that PlatformLanguage is not set.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9408 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2009-11-11 05:19:30 +00:00
parent 3b428adef9
commit 43ffc47f9c
1 changed files with 26 additions and 25 deletions

View File

@ -308,6 +308,9 @@ HiiThunkGetString (
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Rfc4646AsciiLanguage = NULL; Rfc4646AsciiLanguage = NULL;
SupportedLanguages = NULL;
PlatformLanguage = NULL;
Status = EFI_SUCCESS;
if (LanguageString != NULL) { if (LanguageString != NULL) {
Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1); Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);
@ -328,7 +331,6 @@ HiiThunkGetString (
// Iso639ToRfc4646Map. // Iso639ToRfc4646Map.
// //
ASSERT (Rfc4646AsciiLanguage != NULL); ASSERT (Rfc4646AsciiLanguage != NULL);
} }
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle); UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
@ -342,16 +344,13 @@ HiiThunkGetString (
// //
SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle); SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);
if (SupportedLanguages == NULL) { if (SupportedLanguages == NULL) {
goto Error2; goto Done;
} }
// //
// Get the current platform language setting // Get the current platform language setting
// //
PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang"); PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");
if (PlatformLanguage == NULL) {
goto Error1;
}
// //
// Get the best matching language from SupportedLanguages // Get the best matching language from SupportedLanguages
@ -359,20 +358,12 @@ HiiThunkGetString (
BestLanguage = GetBestLanguage ( BestLanguage = GetBestLanguage (
SupportedLanguages, SupportedLanguages,
FALSE, // RFC 4646 mode FALSE, // RFC 4646 mode
(Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "", (Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "", // Highest priority
PlatformLanguage, // Next highest priority (PlatformLanguage != NULL) ? PlatformLanguage : "", // Next highest priority
SupportedLanguages, // Lowest priority SupportedLanguages, // Lowest priority
NULL NULL
); );
if (BestLanguage == NULL) { if (BestLanguage != NULL) {
FreePool (PlatformLanguage);
Error1:
FreePool (SupportedLanguages);
Error2:
Status = EFI_INVALID_PARAMETER;
goto Done;
}
Status = mHiiStringProtocol->GetString ( Status = mHiiStringProtocol->GetString (
mHiiStringProtocol, mHiiStringProtocol,
BestLanguage, BestLanguage,
@ -383,12 +374,22 @@ Error2:
NULL NULL
); );
FreePool (BestLanguage); FreePool (BestLanguage);
} else {
Status = EFI_INVALID_PARAMETER;
}
Done: Done:
if (Rfc4646AsciiLanguage != NULL) { if (Rfc4646AsciiLanguage != NULL) {
FreePool (Rfc4646AsciiLanguage); FreePool (Rfc4646AsciiLanguage);
} }
if (SupportedLanguages != NULL) {
FreePool (SupportedLanguages);
}
if (PlatformLanguage != NULL) {
FreePool (PlatformLanguage);
}
return Status; return Status;
} }