From 0fa3ac1bb8289515bc37a3684749057d63b1fb01 Mon Sep 17 00:00:00 2001 From: niruiyu Date: Fri, 26 Nov 2010 06:33:19 +0000 Subject: [PATCH] Fix the checking logic for the boot option enumeration. Fix the memory leak issue. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11098 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/GenericBdsLib/BdsBoot.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index 8ee0b3e698..61699edeb8 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -1020,18 +1020,26 @@ BdsLibEnumerateAllBootOption ( if (mEnumBootDevice) { LastLang = GetVariable (L"LastEnumLang", &mBdsLibLastLangGuid); PlatLang = GetEfiGlobalVariable (L"PlatformLang"); - if (LastLang == PlatLang) { + ASSERT (PlatLang != NULL); + if ((LastLang != NULL) && (AsciiStrCmp (LastLang, PlatLang) == 0)) { Status = BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder"); + FreePool (LastLang); + FreePool (PlatLang); return Status; } else { Status = gRT->SetVariable ( L"LastEnumLang", &mBdsLibLastLangGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, - sizeof (PlatLang), + AsciiStrSize (PlatLang), PlatLang ); ASSERT_EFI_ERROR (Status); + + if (LastLang != NULL) { + FreePool (LastLang); + } + FreePool (PlatLang); } }