X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkCompatibilityPkg%2FCompatibility%2FFrameworkHiiOnUefiHiiThunk%2FStrings.c;fp=EdkCompatibilityPkg%2FCompatibility%2FFrameworkHiiOnUefiHiiThunk%2FStrings.c;h=d83750bc9b8f16bd70e89e7a19dffee64e50140b;hp=d0b356be5141d6da6ba0597203752b9669221e7e;hb=f324bf4dbeda4d64b769bd005331e8f9404b692d;hpb=b0a5e682d632f139e8b4bd6a642aa15e0518a5c1 diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c index d0b356be51..d83750bc9b 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Strings.c @@ -307,7 +307,6 @@ HiiThunkGetString ( Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); - Iso639AsciiLanguage = NULL; Rfc4646AsciiLanguage = NULL; if (LanguageString != NULL) { @@ -322,6 +321,7 @@ HiiThunkGetString ( // in Iso639. So map it to the Language Identifier defined in RFC4646. // Rfc4646AsciiLanguage = ConvertLanguagesIso639ToRfc4646 (Iso639AsciiLanguage); + FreePool (Iso639AsciiLanguage); // // If Rfc4646AsciiLanguage is NULL, more language mapping must be added to @@ -337,67 +337,56 @@ HiiThunkGetString ( goto Done; } - if (Rfc4646AsciiLanguage == NULL) { - // - // Get the languages that the package specified by HiiHandle supports - // - SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle); - if (SupportedLanguages == NULL) { - goto Error2; - } + // + // Get the languages that the package specified by HiiHandle supports + // + SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle); + if (SupportedLanguages == NULL) { + goto Error2; + } - // - // Get the current platform language setting - // - PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang"); - if (PlatformLanguage == NULL) { - goto Error1; - } + // + // Get the current platform language setting + // + PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang"); + if (PlatformLanguage == NULL) { + goto Error1; + } - // - // Get the best matching language from SupportedLanguages - // - BestLanguage = GetBestLanguage ( - SupportedLanguages, - FALSE, // RFC 4646 mode - PlatformLanguage, // Next highest priority - SupportedLanguages, // Lowest priority - NULL - ); - if (BestLanguage == NULL) { - FreePool (PlatformLanguage); + // + // Get the best matching language from SupportedLanguages + // + BestLanguage = GetBestLanguage ( + SupportedLanguages, + FALSE, // RFC 4646 mode + (Rfc4646AsciiLanguage != NULL) ? Rfc4646AsciiLanguage : "", + PlatformLanguage, // Next highest priority + SupportedLanguages, // Lowest priority + NULL + ); + if (BestLanguage == NULL) { + FreePool (PlatformLanguage); Error1: - FreePool (SupportedLanguages); + FreePool (SupportedLanguages); Error2: - Status = EFI_INVALID_PARAMETER; - goto Done; - } - - Status = mHiiStringProtocol->GetString ( - mHiiStringProtocol, - BestLanguage, - UefiHiiHandle, - Token, - StringBuffer, - BufferLengthTemp, - NULL - ); - FreePool (BestLanguage); - } else { - Status = mHiiStringProtocol->GetString ( - mHiiStringProtocol, - Rfc4646AsciiLanguage, - UefiHiiHandle, - Token, - StringBuffer, - BufferLengthTemp, - NULL - ); + Status = EFI_INVALID_PARAMETER; + goto Done; } + Status = mHiiStringProtocol->GetString ( + mHiiStringProtocol, + BestLanguage, + UefiHiiHandle, + Token, + StringBuffer, + BufferLengthTemp, + NULL + ); + FreePool (BestLanguage); + Done: - if (Iso639AsciiLanguage != NULL) { - FreePool (Iso639AsciiLanguage); + if (Rfc4646AsciiLanguage != NULL) { + FreePool (Rfc4646AsciiLanguage); } return Status;