]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the checking logic for the boot option enumeration.
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Nov 2010 06:33:19 +0000 (06:33 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Nov 2010 06:33:19 +0000 (06:33 +0000)
Fix the memory leak issue.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11098 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c

index 8ee0b3e6986a27749ee628d2fa3882346d0c9ac2..61699edeb892c51df30df8ac2d0f4dd094d864b0 100644 (file)
@@ -1020,18 +1020,26 @@ BdsLibEnumerateAllBootOption (
   if (mEnumBootDevice) {\r
     LastLang = GetVariable (L"LastEnumLang", &mBdsLibLastLangGuid);\r
     PlatLang = GetEfiGlobalVariable (L"PlatformLang");\r
-    if (LastLang == PlatLang) {\r
+    ASSERT (PlatLang != NULL);\r
+    if ((LastLang != NULL) && (AsciiStrCmp (LastLang, PlatLang) == 0)) {\r
       Status = BdsLibBuildOptionFromVar (BdsBootOptionList, L"BootOrder");\r
+      FreePool (LastLang);\r
+      FreePool (PlatLang);\r
       return Status;\r
     } else {\r
       Status = gRT->SetVariable (\r
         L"LastEnumLang",\r
         &mBdsLibLastLangGuid,\r
         EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-        sizeof (PlatLang),\r
+        AsciiStrSize (PlatLang),\r
         PlatLang\r
         );\r
       ASSERT_EFI_ERROR (Status);\r
+\r
+      if (LastLang != NULL) {\r
+        FreePool (LastLang);\r
+      }\r
+      FreePool (PlatLang);\r
     }\r
   }\r
 \r