]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
IntelFrameworkModulePkg: Fix a memory leak bug in BdsDxe driver.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMaint / BBSsupport.c
index db0fed5834d512b415784f86e537d6f745ef131c..6a0b525f1581eafd6e8923929b4767413e6e0e72 100644 (file)
@@ -3,7 +3,7 @@
   and manage the legacy boot option, all legacy boot option is getting from\r
   the legacy BBS table.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -143,11 +143,15 @@ OrderLegacyBootOption4SameType (
                   BootOrderSize,\r
                   BootOrder\r
                   );\r
+  //\r
+  // Changing content without increasing its size with current variable implementation shouldn't fail.\r
+  //\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   FreePool (NewBootOption);\r
   FreePool (DeviceTypeArray);\r
   FreePool (BbsIndexArray);\r
+  FreePool (BootOrder);\r
 }\r
 \r
 /**\r
@@ -171,6 +175,7 @@ GroupMultipleLegacyBootOption4SameType (
   VOID\r
   )\r
 {\r
+  EFI_STATUS                   Status;\r
   UINTN                        Index;\r
   UINTN                        DeviceIndex;\r
   UINTN                        DeviceTypeIndex[7];\r
@@ -233,13 +238,17 @@ GroupMultipleLegacyBootOption4SameType (
     FreePool (BootOption);\r
   }\r
 \r
-  gRT->SetVariable (\r
-         L"BootOrder",\r
-         &gEfiGlobalVariableGuid,\r
-         EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-         BootOrderSize,\r
-         BootOrder\r
-         );\r
+  Status = gRT->SetVariable (\r
+                  L"BootOrder",\r
+                  &gEfiGlobalVariableGuid,\r
+                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                  BootOrderSize,\r
+                  BootOrder\r
+                  );\r
+  //\r
+  // Changing content without increasing its size with current variable implementation shouldn't fail.\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
   FreePool (BootOrder);\r
 }\r
 \r