From 0b09813f57ee1d316aadf6c6edefb5db8d618573 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Fri, 27 Mar 2009 03:24:58 +0000 Subject: [PATCH] Retire RFC_3066_ENTRY_SIZE definition. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7966 6f19259b-4bc3-4df7-8a09-765794883524 --- .../FrameworkHiiOnUefiHiiThunk/HiiDatabase.c | 38 ++++++++++++++----- .../Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c | 6 +-- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c index 1bf17c174c..4572254d2c 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c @@ -312,7 +312,7 @@ LangCodes3066To639 ( ) { CHAR8 *AsciiLangCodes; - CHAR8 Lang[RFC_3066_ENTRY_SIZE]; + CHAR8 *Lang; UINTN Index; UINTN Count; EFI_STATUS Status; @@ -320,6 +320,14 @@ LangCodes3066To639 ( ASSERT (LangCodes3066 != NULL); ASSERT (LangCodes639 != NULL); + // + // Allocate working buffer to contain substring of LangCodes3066. + // + Lang = AllocatePool (AsciiStrSize (LangCodes3066)); + if (Lang != NULL) { + return EFI_OUT_OF_RESOURCES; + } + // // Count the number of RFC 3066 language codes. // @@ -337,7 +345,8 @@ LangCodes3066To639 ( // *LangCodes639 = AllocateZeroPool (ISO_639_2_ENTRY_SIZE * Count + 1); if (*LangCodes639 == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } AsciiLangCodes = LangCodes3066; @@ -348,7 +357,11 @@ LangCodes3066To639 ( ASSERT_EFI_ERROR (Status); } - return EFI_SUCCESS; + Status = EFI_SUCCESS; + +Done: + FreePool (Lang); + return Status; } /** @@ -454,9 +467,9 @@ HiiGetSecondaryLanguages ( OUT EFI_STRING *LanguageString ) { - HII_THUNK_PRIVATE_DATA *Private; + HII_THUNK_PRIVATE_DATA *Private; EFI_HII_HANDLE UefiHiiHandle; - CHAR8 PrimaryLang3066[RFC_3066_ENTRY_SIZE]; + CHAR8 *PrimaryLang3066; CHAR8 *PrimaryLang639; CHAR8 *SecLangCodes3066; CHAR8 *SecLangCodes639; @@ -465,8 +478,9 @@ HiiGetSecondaryLanguages ( Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); - SecLangCodes639 = NULL; - SecLangCodes3066 = NULL; + SecLangCodes639 = NULL; + SecLangCodes3066 = NULL; + PrimaryLang3066 = NULL; UnicodeSecLangCodes639 = NULL; UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle); @@ -482,8 +496,8 @@ HiiGetSecondaryLanguages ( UnicodeStrToAsciiStr (PrimaryLanguage, PrimaryLang639); - Status = ConvertIso639LanguageToRfc3066Language (PrimaryLang639, PrimaryLang3066); - ASSERT_EFI_ERROR (Status); + PrimaryLang3066 = ConvertIso639LanguageToRfc3066Language (PrimaryLang639); + ASSERT_EFI_ERROR (PrimaryLang3066 != NULL); SecLangCodes3066 = HiiLibGetSupportedSecondaryLanguages (UefiHiiHandle, PrimaryLang3066); @@ -512,9 +526,15 @@ Done: if (PrimaryLang639 != NULL) { FreePool (PrimaryLang639); } + if (SecLangCodes639 != NULL) { FreePool (SecLangCodes639); } + + if (PrimaryLang3066 != NULL) { + FreePool (PrimaryLang3066); + } + if (SecLangCodes3066 != NULL) { FreePool (SecLangCodes3066); } diff --git a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c index b8cfd5dc66..4ab74bad83 100644 --- a/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c +++ b/EdkCompatibilityPkg/Compatibility/Uc2OnUcThunk/Uc2OnUcThunk.c @@ -248,10 +248,8 @@ UcNotificationEvent ( // // Fill in rest of private data structure // - Private->UC2.SupportedLanguages = AllocateZeroPool (RFC_3066_ENTRY_SIZE); - Status = ConvertIso639LanguageToRfc3066Language (Private->UC->SupportedLanguages, Private->UC2.SupportedLanguages); - - if (!EFI_ERROR (Status)) { + Private->UC2.SupportedLanguages = ConvertIso639LanguageToRfc3066Language (Private->UC->SupportedLanguages); + if (Private->UC2.SupportedLanguages != NULL) { // // Install Firmware Volume Protocol onto same handle