diff options
author | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-06-06 08:41:58 +0000 |
---|---|---|
committer | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-06-06 08:41:58 +0000 |
commit | 2d1f3dd497f343bc54b4a164d4e9f015ae04f7dc (patch) | |
tree | c898ba3e282ebeed9d8da62b66bdd43ef540acab | |
parent | d6f19057f048bdb1afb84fb8dddcb6373c0b684f (diff) | |
download | edk2-platforms-2d1f3dd497f343bc54b4a164d4e9f015ae04f7dc.tar.xz |
Fix memory leak issues.
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
-rw-r--r-- | IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c | 6 | ||||
-rw-r--r-- | IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c index 3d1ccf9dc2..a432fb24a4 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c @@ -825,6 +825,7 @@ BdsLibGetVariableAndSize ( //
Buffer = AllocateZeroPool (BufferSize);
if (Buffer == NULL) {
+ *VariableSize = 0;
return NULL;
}
//
@@ -832,10 +833,15 @@ BdsLibGetVariableAndSize ( //
Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
if (EFI_ERROR (Status)) {
+ FreePool (Buffer);
BufferSize = 0;
+ Buffer = NULL;
}
}
+ ASSERT (((Buffer == NULL) && (BufferSize == 0)) ||
+ ((Buffer != NULL) && (BufferSize != 0))
+ );
*VariableSize = BufferSize;
return Buffer;
}
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c index 7879e18a41..db0fed5834 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c @@ -76,6 +76,8 @@ OrderLegacyBootOption4SameType ( *EnBootOptionCount = 0;
Index = 0;
+ ASSERT (BbsIndexArray != NULL);
+ ASSERT (DeviceTypeArray != NULL);
ASSERT (*EnBootOption != NULL);
ASSERT (*DisBootOption != NULL);
@@ -84,7 +86,7 @@ OrderLegacyBootOption4SameType ( UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);
InitializeListHead (&List);
BootOption = BdsLibVariableToOption (&List, OptionName);
- ASSERT_EFI_ERROR (BootOption != NULL);
+ ASSERT (BootOption != NULL);
if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&
(DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {
@@ -111,6 +113,7 @@ OrderLegacyBootOption4SameType ( //
StartPosition = BootOrderSize / sizeof (UINT16);
NewBootOption = AllocatePool (DevOrderCount * sizeof (UINT16));
+ ASSERT (NewBootOption != NULL);
while (DevOrderCount-- != 0) {
for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {
if (BbsIndexArray[Index] == (DevOrder[DevOrderCount] & 0xFF)) {
@@ -191,7 +194,7 @@ GroupMultipleLegacyBootOption4SameType ( UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);
InitializeListHead (&List);
BootOption = BdsLibVariableToOption (&List, OptionName);
- ASSERT_EFI_ERROR (BootOption != NULL);
+ ASSERT (BootOption != NULL);
if ((DevicePathType (BootOption->DevicePath) == BBS_DEVICE_PATH) &&
(DevicePathSubType (BootOption->DevicePath) == BBS_BBS_DP)) {
|