]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix memory leak issues.
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Jun 2012 08:41:58 +0000 (08:41 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Jun 2012 08:41:58 +0000 (08:41 +0000)
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13428 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c

index 3d1ccf9dc2c5ffd3872a85e26733d01696742c39..a432fb24a4b8f86cb32e09c014b372fda8c23e3d 100644 (file)
@@ -825,6 +825,7 @@ BdsLibGetVariableAndSize (
     //\r
     Buffer = AllocateZeroPool (BufferSize);\r
     if (Buffer == NULL) {\r
+      *VariableSize = 0;\r
       return NULL;\r
     }\r
     //\r
@@ -832,10 +833,15 @@ BdsLibGetVariableAndSize (
     //\r
     Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);\r
     if (EFI_ERROR (Status)) {\r
+      FreePool (Buffer);\r
       BufferSize = 0;\r
+      Buffer     = NULL;\r
     }\r
   }\r
 \r
+  ASSERT (((Buffer == NULL) && (BufferSize == 0)) ||\r
+          ((Buffer != NULL) && (BufferSize != 0))\r
+          );\r
   *VariableSize = BufferSize;\r
   return Buffer;\r
 }\r
index 7879e18a4120b6d8abf388aee6baa88539f9f058..db0fed5834d512b415784f86e537d6f745ef131c 100644 (file)
@@ -76,6 +76,8 @@ OrderLegacyBootOption4SameType (
   *EnBootOptionCount  = 0;\r
   Index               = 0;\r
 \r
+  ASSERT (BbsIndexArray != NULL);\r
+  ASSERT (DeviceTypeArray != NULL);\r
   ASSERT (*EnBootOption != NULL);\r
   ASSERT (*DisBootOption != NULL);\r
 \r
@@ -84,7 +86,7 @@ OrderLegacyBootOption4SameType (
     UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);\r
     InitializeListHead (&List);\r
     BootOption = BdsLibVariableToOption (&List, OptionName);\r
-    ASSERT_EFI_ERROR (BootOption != NULL);\r
+    ASSERT (BootOption != NULL);\r
     \r
     if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&\r
         (DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {\r
@@ -111,6 +113,7 @@ OrderLegacyBootOption4SameType (
   //\r
   StartPosition = BootOrderSize / sizeof (UINT16);\r
   NewBootOption = AllocatePool (DevOrderCount * sizeof (UINT16));\r
+  ASSERT (NewBootOption != NULL);\r
   while (DevOrderCount-- != 0) {\r
     for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {\r
       if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {\r
@@ -191,7 +194,7 @@ GroupMultipleLegacyBootOption4SameType (
     UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);\r
     InitializeListHead (&List);\r
     BootOption = BdsLibVariableToOption (&List, OptionName);\r
-    ASSERT_EFI_ERROR (BootOption != NULL);\r
+    ASSERT (BootOption != NULL);\r
 \r
     if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&\r
         (DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {\r