summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-10-30 07:32:46 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-10-30 07:32:46 +0000
commit676df92c2c0c5bdeb0f8e27349f5dd467928ce09 (patch)
tree68999d69951d5884d39a206c5c81ba59d91157fb /MdeModulePkg/Universal
parentbb1d8ee66943c3d126abbfc007159eb0fe458927 (diff)
downloadedk2-platforms-676df92c2c0c5bdeb0f8e27349f5dd467928ce09.tar.xz
Remove SafeFreePool from MemoryAllocationLib as this API's name is misleading. Its implementation only check if a pointer is NULL. If a garbage pointer is passed in, the gBS->FreePool will still ASSERT in debug build and return error code.
It is recommended that module writer should keep track how a pointer is allocated and free it after use. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6306 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c50
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/BmLib.c10
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c16
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c85
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c12
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c18
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c37
-rw-r--r--MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c4
-rw-r--r--MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c36
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf2
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c126
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Database.c135
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Font.c90
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Image.c39
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/String.c20
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Expression.c44
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c60
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c56
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c8
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Ui.c4
20 files changed, 522 insertions, 330 deletions
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
index e11e279247..96000749c9 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
@@ -324,7 +324,8 @@ BdsCreateLegacyBootOption (
Buffer
);
- SafeFreePool (Buffer);
+ FreePool (Buffer);
+
Buffer = NULL;
NewBootOrderList = AllocateZeroPool (*BootOrderListSize + sizeof (UINT16));
@@ -334,12 +335,11 @@ BdsCreateLegacyBootOption (
return EFI_OUT_OF_RESOURCES;
}
- if (NULL != *BootOrderList) {
+ if (*BootOrderList != NULL) {
CopyMem (NewBootOrderList, *BootOrderList, *BootOrderListSize);
+ FreePool (*BootOrderList);
}
- SafeFreePool (*BootOrderList);
-
BootOrderLastIndex = (UINTN) (*BootOrderListSize / sizeof (UINT16));
NewBootOrderList[BootOrderLastIndex] = CurrentBootOptionNo;
*BootOrderListSize += sizeof (UINT16);
@@ -462,7 +462,9 @@ BdsDeleteAllInvalidLegacyBootOptions (
&BootOptionSize
);
if (NULL == BootOptionVar) {
- SafeFreePool (BootOrder);
+ if (BootOrder != NULL) {
+ FreePool (BootOrder);
+ }
return EFI_OUT_OF_RESOURCES;
}
@@ -470,7 +472,9 @@ BdsDeleteAllInvalidLegacyBootOptions (
// Skip Non-Legacy boot options
//
if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, &BbsIndex)) {
- SafeFreePool (BootOptionVar);
+ if (BootOptionVar!= NULL) {
+ FreePool (BootOptionVar);
+ }
Index++;
continue;
}
@@ -499,7 +503,9 @@ BdsDeleteAllInvalidLegacyBootOptions (
continue;
}
- SafeFreePool (BootOptionVar);
+ if (BootOptionVar != NULL) {
+ FreePool (BootOptionVar);
+ }
//
// should delete
//
@@ -525,7 +531,9 @@ BdsDeleteAllInvalidLegacyBootOptions (
EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);
}
- SafeFreePool (BootOrder);
+ if (BootOrder != NULL) {
+ FreePool (BootOrder);
+ }
return Status;
}
@@ -588,19 +596,19 @@ BdsFindLegacyBootOptionByDevType (
// Skip Non-legacy boot option
//
if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, BbsIndex)) {
- SafeFreePool (BootOptionVar);
+ FreePool (BootOptionVar);
continue;
}
if (BbsEntry->DeviceType != DevType) {
- SafeFreePool (BootOptionVar);
+ FreePool (BootOptionVar);
continue;
}
*Attribute = *(UINT32 *) BootOptionVar;
*OptionNumber = Index;
Found = TRUE;
- SafeFreePool (BootOptionVar);
+ FreePool (BootOptionVar);
break;
}
@@ -767,7 +775,7 @@ BdsAddNonExistingLegacyBootOptions (
}
if (BootOrder != NULL) {
- SafeFreePool (BootOrder);
+ FreePool (BootOrder);
}
return Status;
@@ -952,7 +960,7 @@ BdsCreateDevOrder (
TotalSize,
DevOrder
);
- SafeFreePool (DevOrder);
+ FreePool (DevOrder);
return Status;
}
@@ -1382,7 +1390,7 @@ BdsUpdateLegacyDevOrder (
}
}
- SafeFreePool (DevOrder);
+ FreePool (DevOrder);
Status = gRT->SetVariable (
VAR_LEGACY_DEV_ORDER,
@@ -1391,7 +1399,7 @@ BdsUpdateLegacyDevOrder (
TotalSize,
NewDevOrder
);
- SafeFreePool (NewDevOrder);
+ FreePool (NewDevOrder);
return Status;
}
@@ -1442,7 +1450,7 @@ BdsSetBootPriority4SameTypeDev (
}
if (DevOrder >= OrigBuffer + DevOrderSize) {
- SafeFreePool (OrigBuffer);
+ FreePool (OrigBuffer);
return EFI_NOT_FOUND;
}
@@ -1463,7 +1471,7 @@ BdsSetBootPriority4SameTypeDev (
}
}
- SafeFreePool (OrigBuffer);
+ FreePool (OrigBuffer);
return EFI_SUCCESS;
}
@@ -1619,7 +1627,7 @@ BdsRefreshBbsTableForBoot (
Ptr += StrSize ((UINT16 *) Ptr);
DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
if (BBS_DEVICE_PATH != DevPath->Type || BBS_BBS_DP != DevPath->SubType) {
- SafeFreePool (BootOptionVar);
+ FreePool (BootOptionVar);
continue;
}
@@ -1628,7 +1636,7 @@ BdsRefreshBbsTableForBoot (
//
// We don't want to process twice for a device type
//
- SafeFreePool (BootOptionVar);
+ FreePool (BootOptionVar);
continue;
}
@@ -1637,14 +1645,14 @@ BdsRefreshBbsTableForBoot (
LocalBbsTable,
&Priority
);
- SafeFreePool (BootOptionVar);
+ FreePool (BootOptionVar);
if (EFI_ERROR (Status)) {
break;
}
}
if (BootOrder != NULL) {
- SafeFreePool (BootOrder);
+ FreePool (BootOrder);
}
//
// For debug
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/BmLib.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/BmLib.c
index 2e4b1c6fb2..9ef2f7f034 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/BmLib.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/BmLib.c
@@ -125,7 +125,9 @@ EfiGrowBuffer (
TryAgain = FALSE;
if (*Status == EFI_BUFFER_TOO_SMALL) {
- SafeFreePool (*Buffer);
+ if (*Buffer != NULL) {
+ FreePool (*Buffer);
+ }
*Buffer = AllocateZeroPool (BufferSize);
@@ -139,7 +141,7 @@ EfiGrowBuffer (
// If there's an error, free the buffer
//
if (!TryAgain && EFI_ERROR (*Status) && (*Buffer != NULL)) {
- SafeFreePool (*Buffer);
+ FreePool (*Buffer);
*Buffer = NULL;
}
@@ -201,7 +203,7 @@ EfiLibDeleteVariable (
//
Status = gRT->SetVariable (VarName, VarGuid, VAR_FLAG, 0, NULL);
ASSERT (!EFI_ERROR (Status));
- SafeFreePool (VarBuf);
+ FreePool (VarBuf);
}
return Status;
@@ -373,7 +375,7 @@ EfiReallocatePool (
CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
}
- SafeFreePool (OldPool);
+ FreePool (OldPool);
}
return NewPool;
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
index fffcd68140..ac31398987 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
@@ -811,7 +811,7 @@ InitializeBM (
//
Ptr = AllocateZeroPool (sizeof (BM_LOAD_CONTEXT) + sizeof (BM_FILE_CONTEXT) + sizeof (BM_HANDLE_CONTEXT) + sizeof (BM_MENU_ENTRY));
if (Ptr == NULL) {
- SafeFreePool (BmmCallbackInfo);
+ FreePool (BmmCallbackInfo);
return EFI_OUT_OF_RESOURCES;
}
@@ -917,8 +917,8 @@ InitializeBM (
gUpdateData.BufferSize = UPDATE_DATA_SIZE;
gUpdateData.Data = AllocateZeroPool (UPDATE_DATA_SIZE);
if (gUpdateData.Data == NULL) {
- SafeFreePool (BmmCallbackInfo->LoadContext);
- SafeFreePool (BmmCallbackInfo);
+ FreePool (BmmCallbackInfo->LoadContext);
+ FreePool (BmmCallbackInfo);
return EFI_OUT_OF_RESOURCES;
}
@@ -1020,9 +1020,9 @@ InitializeBM (
FreeAllMenu ();
- SafeFreePool (BmmCallbackInfo->LoadContext);
- SafeFreePool (BmmCallbackInfo);
- SafeFreePool (gUpdateData.Data);
+ FreePool (BmmCallbackInfo->LoadContext);
+ FreePool (BmmCallbackInfo);
+ FreePool (gUpdateData.Data);
gUpdateData.Data = NULL;
return Status;
@@ -1205,7 +1205,7 @@ CleanUpStringDepository (
CurrentListNode = StringDepository->ListHead;
for (NodeIndex = 0; NodeIndex < StringDepository->TotalNodeNumber; NodeIndex++) {
NextListNode = CurrentListNode->Next;
- SafeFreePool (CurrentListNode);
+ FreePool (CurrentListNode);
CurrentListNode = NextListNode;
}
@@ -1214,7 +1214,7 @@ CleanUpStringDepository (
//
// Release string depository.
//
- SafeFreePool (FileOptionStrDepository);
+ FreePool (FileOptionStrDepository);
}
/**
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
index 020d63a8c6..85ba61707f 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c
@@ -83,7 +83,7 @@ BOpt_CreateMenuEntry (
MenuEntry->VariableContext = AllocateZeroPool (ContextSize);
if (NULL == MenuEntry->VariableContext) {
- SafeFreePool (MenuEntry);
+ FreePool (MenuEntry);
return NULL;
}
@@ -116,59 +116,65 @@ BOpt_DestroyMenuEntry (
switch (MenuEntry->ContextSelection) {
case BM_LOAD_CONTEXT_SELECT:
LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;
- SafeFreePool (LoadContext->FilePathList);
- SafeFreePool (LoadContext->LoadOption);
- SafeFreePool (LoadContext->OptionalData);
- SafeFreePool (LoadContext);
+ FreePool (LoadContext->FilePathList);
+ FreePool (LoadContext->LoadOption);
+ if (LoadContext->OptionalData != NULL) {
+ FreePool (LoadContext->OptionalData);
+ }
+ FreePool (LoadContext);
break;
case BM_FILE_CONTEXT_SELECT:
FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;
if (!FileContext->IsRoot) {
- SafeFreePool (FileContext->DevicePath);
+ FreePool (FileContext->DevicePath);
} else {
if (FileContext->FHandle != NULL) {
FileContext->FHandle->Close (FileContext->FHandle);
}
}
- SafeFreePool (FileContext->FileName);
- SafeFreePool (FileContext->Info);
- SafeFreePool (FileContext);
+ if (FileContext->FileName != NULL) {
+ FreePool (FileContext->FileName);
+ }
+ if (FileContext->Info != NULL) {
+ FreePool (FileContext->Info);
+ }
+ FreePool (FileContext);
break;
case BM_CONSOLE_CONTEXT_SELECT:
ConsoleContext = (BM_CONSOLE_CONTEXT *) MenuEntry->VariableContext;
- SafeFreePool (ConsoleContext->DevicePath);
- SafeFreePool (ConsoleContext);
+ FreePool (ConsoleContext->DevicePath);
+ FreePool (ConsoleContext);
break;
case BM_TERMINAL_CONTEXT_SELECT:
TerminalContext = (BM_TERMINAL_CONTEXT *) MenuEntry->VariableContext;
- SafeFreePool (TerminalContext->DevicePath);
- SafeFreePool (TerminalContext);
+ FreePool (TerminalContext->DevicePath);
+ FreePool (TerminalContext);
break;
case BM_HANDLE_CONTEXT_SELECT:
HandleContext = (BM_HANDLE_CONTEXT *) MenuEntry->VariableContext;
- SafeFreePool (HandleContext);
+ FreePool (HandleContext);
break;
case BM_LEGACY_DEV_CONTEXT_SELECT:
LegacyDevContext = (BM_LEGACY_DEVICE_CONTEXT *) MenuEntry->VariableContext;
- SafeFreePool (LegacyDevContext);
+ FreePool (LegacyDevContext);
default:
break;
}
- SafeFreePool (MenuEntry->DisplayString);
+ FreePool (MenuEntry->DisplayString);
if (NULL != MenuEntry->HelpString) {
- SafeFreePool (MenuEntry->HelpString);
+ FreePool (MenuEntry->HelpString);
}
- SafeFreePool (MenuEntry);
+ FreePool (MenuEntry);
}
/**
@@ -278,7 +284,7 @@ BOpt_FindFileSystem (
if (BlkIo->Media->RemovableMedia) {
Buffer = AllocateZeroPool (BlkIo->Media->BlockSize);
if (NULL == Buffer) {
- SafeFreePool (BlkIoHandle);
+ FreePool (BlkIoHandle);
return EFI_OUT_OF_RESOURCES;
}
@@ -289,10 +295,10 @@ BOpt_FindFileSystem (
BlkIo->Media->BlockSize,
Buffer
);
- SafeFreePool (Buffer);
+ FreePool (Buffer);
}
}
- SafeFreePool (BlkIoHandle);
+ FreePool (BlkIoHandle);
}
//
@@ -332,7 +338,7 @@ BOpt_FindFileSystem (
//
MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);
if (NULL == MenuEntry) {
- SafeFreePool (SimpleFsHandle);
+ FreePool (SimpleFsHandle);
return EFI_OUT_OF_RESOURCES;
}
@@ -390,7 +396,7 @@ BOpt_FindFileSystem (
}
if (NoSimpleFsHandles != 0) {
- SafeFreePool (SimpleFsHandle);
+ FreePool (SimpleFsHandle);
}
//
// Searching for handles that support Load File protocol
@@ -407,7 +413,7 @@ BOpt_FindFileSystem (
for (Index = 0; Index < NoLoadFileHandles; Index++) {
MenuEntry = BOpt_CreateMenuEntry (BM_FILE_CONTEXT_SELECT);
if (NULL == MenuEntry) {
- SafeFreePool (LoadFileHandle);
+ FreePool (LoadFileHandle);
return EFI_OUT_OF_RESOURCES;
}
@@ -438,7 +444,7 @@ BOpt_FindFileSystem (
}
if (NoLoadFileHandles != 0) {
- SafeFreePool (LoadFileHandle);
+ FreePool (LoadFileHandle);
}
//
@@ -676,7 +682,7 @@ BOpt_FindFiles (
}
DirectoryMenu.MenuNumber = OptionNumber;
- SafeFreePool (DirInfo);
+ FreePool (DirInfo);
return EFI_SUCCESS;
}
@@ -898,7 +904,7 @@ BOpt_GetBootOptions (
if (BootNext != NULL) {
if (BootNextSize != sizeof (UINT16)) {
- SafeFreePool (BootNext);
+ FreePool (BootNext);
BootNext = NULL;
}
}
@@ -923,7 +929,7 @@ BOpt_GetBootOptions (
}
CopyMem (LoadOption, LoadOptionFromVar, BootOptionSize);
- SafeFreePool (LoadOptionFromVar);
+ FreePool (LoadOptionFromVar);
if (BootNext != NULL) {
BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);
@@ -932,7 +938,7 @@ BOpt_GetBootOptions (
}
if (0 == (*((UINT32 *) LoadOption) & LOAD_OPTION_ACTIVE)) {
- SafeFreePool (LoadOption);
+ FreePool (LoadOption);
continue;
}
//
@@ -1054,8 +1060,12 @@ BOpt_GetBootOptions (
MenuCount++;
}
- SafeFreePool (BootNext);
- SafeFreePool (BootOrderList);
+ if (BootNext != NULL) {
+ FreePool (BootNext);
+ }
+ if (BootOrderList != NULL) {
+ FreePool (BootOrderList);
+ }
BootOptionMenu.MenuNumber = MenuCount;
return MenuCount;
}
@@ -1318,7 +1328,7 @@ BOpt_FindDrivers (
NewMenuEntry = BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT);
if (NULL == NewMenuEntry) {
- SafeFreePool (DevicePathHandle);
+ FreePool (DevicePathHandle);
return EFI_OUT_OF_RESOURCES;
}
@@ -1332,7 +1342,10 @@ BOpt_FindDrivers (
InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);
}
- SafeFreePool (DevicePathHandle);
+
+ if (DevicePathHandle != NULL) {
+ FreePool (DevicePathHandle);
+ }
DriverMenu.MenuNumber = OptionNumber;
return EFI_SUCCESS;
@@ -1545,7 +1558,7 @@ BOpt_GetDriverOptions (
}
CopyMem (LoadOption, LoadOptionFromVar, DriverOptionSize);
- SafeFreePool (LoadOptionFromVar);
+ FreePool (LoadOptionFromVar);
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
if (NULL == NewMenuEntry) {
@@ -1631,7 +1644,9 @@ BOpt_GetDriverOptions (
}
- SafeFreePool (DriverOrderList);
+ if (DriverOrderList != NULL) {
+ FreePool (DriverOrderList);
+ }
DriverOptionMenu.MenuNumber = Index;
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
index 635dc34173..b9ffa056da 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
@@ -419,7 +419,7 @@ LocateSerialIo (
if (CompareMem (&Acpi->HID, &Match, sizeof (UINT32)) == 0) {
NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);
if (NewMenuEntry == NULL) {
- SafeFreePool (Handles);
+ FreePool (Handles);
return EFI_OUT_OF_RESOURCES;
}
@@ -472,7 +472,9 @@ LocateSerialIo (
TerminalMenu.MenuNumber++;
}
}
- SafeFreePool (Handles);
+ if (Handles != NULL) {
+ FreePool (Handles);
+ }
//
// Get L"ConOut", L"ConIn" and L"ErrOut" from the Var
@@ -515,7 +517,9 @@ LocateSerialIo (
NewTerminalContext->DevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &Vendor
);
- SafeFreePool (NewMenuEntry->HelpString);
+ if (NewMenuEntry->HelpString != NULL) {
+ FreePool (NewMenuEntry->HelpString);
+ }
//
// NewMenuEntry->HelpString = DevicePathToStr (NewDevicePath);
// NewMenuEntry->DisplayString = NewMenuEntry->HelpString;
@@ -999,6 +1003,6 @@ GetConsoleOutMode (
}
}
}
+ FreePool (ModeInfo);
}
- SafeFreePool (ModeInfo);
}
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
index 3de4a0d687..2ffb1ff037 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/UpdatePage.c
@@ -549,7 +549,7 @@ UpdateOrderPage (
);
}
- SafeFreePool (IfrOptionList);
+ FreePool (IfrOptionList);
UpdatePageEnd (CallbackData);
@@ -626,7 +626,7 @@ UpdateBootNextPage (
&gUpdateData
);
- SafeFreePool (IfrOptionList);
+ FreePool (IfrOptionList);
}
UpdatePageEnd (CallbackData);
@@ -771,8 +771,8 @@ UpdateConModePage (
ValidMode,
&gUpdateData
);
- SafeFreePool (IfrOptionList);
- SafeFreePool (ModeToken);
+ FreePool (IfrOptionList);
+ FreePool (ModeToken);
UpdatePageEnd (CallbackData);
}
@@ -946,7 +946,7 @@ UpdateTerminalPage (
&gUpdateData
);
- SafeFreePool (IfrOptionList);
+ FreePool (IfrOptionList);
UpdatePageEnd (CallbackData);
}
@@ -1063,14 +1063,14 @@ GetLegacyBootOptionVar (
(BBS_BBS_DP == DevicePath->SubType)
) {
*OptionIndex = OrderBuffer[Index];
- SafeFreePool (OrderBuffer);
+ FreePool (OrderBuffer);
return OptionBuffer;
} else {
- SafeFreePool (OptionBuffer);
+ FreePool (OptionBuffer);
}
}
- SafeFreePool (OrderBuffer);
+ FreePool (OrderBuffer);
return NULL;
}
@@ -1271,7 +1271,7 @@ UpdateSetLegacyDeviceOrderPage (
CopyMem (OldData, LegacyOrder, 100);
if (IfrOptionList != NULL) {
- SafeFreePool (IfrOptionList);
+ FreePool (IfrOptionList);
IfrOptionList = NULL;
}
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
index b97af5cd29..622093c8bb 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
@@ -122,7 +122,7 @@ Var_ChangeBootOrder (
//
if (BootOrderList != NULL) {
EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);
- SafeFreePool (BootOrderList);
+ FreePool (BootOrderList);
BootOrderList = NULL;
}
//
@@ -268,7 +268,7 @@ Var_ChangeDriverOrder (
//
if (DriverOrderList != NULL) {
EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);
- SafeFreePool (DriverOrderList);
+ FreePool (DriverOrderList);
DriverOrderList = NULL;
}
@@ -407,7 +407,7 @@ Var_UpdateConsoleOption (
ConDevicePath = EfiLibGetVariable (ConsoleName, &gEfiGlobalVariableGuid);
if (ConDevicePath != NULL) {
EfiLibDeleteVariable (ConsoleName, &gEfiGlobalVariableGuid);
- SafeFreePool (ConDevicePath);
+ FreePool (ConDevicePath);
ConDevicePath = NULL;
};
@@ -689,10 +689,11 @@ Var_UpdateDriverOption (
NewDriverOrderList
);
ASSERT_EFI_ERROR (Status);
- SafeFreePool (DriverOrderList);
+ if (DriverOrderList != NULL) {
+ FreePool (DriverOrderList);
+ }
DriverOrderList = NULL;
- SafeFreePool (NewDriverOrderList);
- NewDriverOrderList = NULL;
+ FreePool (NewDriverOrderList);
InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
DriverOptionMenu.MenuNumber++;
@@ -849,6 +850,7 @@ Var_UpdateBootOption (
if (BootOrderList != NULL) {
EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);
+ FreePool (BootOrderList);
}
Status = gRT->SetVariable (
@@ -860,9 +862,7 @@ Var_UpdateBootOption (
);
ASSERT_EFI_ERROR (Status);
- SafeFreePool (BootOrderList);
- BootOrderList = NULL;
- SafeFreePool (NewBootOrderList);
+ FreePool (NewBootOrderList);
NewBootOrderList = NULL;
InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
BootOptionMenu.MenuNumber++;
@@ -976,6 +976,7 @@ Var_UpdateBootOrder (
//
if (BootOrderList != NULL) {
EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);
+ FreePool (BootOrderList);
}
for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
@@ -989,8 +990,7 @@ Var_UpdateBootOrder (
BootOrderListSize,
NewBootOrderList
);
- SafeFreePool (BootOrderList);
- SafeFreePool (NewBootOrderList);
+ FreePool (NewBootOrderList);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1048,6 +1048,7 @@ Var_UpdateDriverOrder (
//
if (DriverOrderList != NULL) {
EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);
+ FreePool (DriverOrderList);
}
for (Index = 0; Index < DriverOrderListSize; Index++) {
@@ -1065,8 +1066,6 @@ Var_UpdateDriverOrder (
return Status;
}
- SafeFreePool (DriverOrderList);
-
BOpt_FreeMenu (&DriverOptionMenu);
BOpt_GetDriverOptions (CallbackData);
return EFI_SUCCESS;
@@ -1190,13 +1189,13 @@ Var_UpdateBBSOption (
}
if (VarData >= VarData + VarSize) {
- SafeFreePool (OriginalPtr);
+ FreePool (OriginalPtr);
return EFI_NOT_FOUND;
}
NewOrder = (UINT16 *) AllocateZeroPool (DevOrder->Length - sizeof (UINT16));
if (NULL == NewOrder) {
- SafeFreePool (VarData);
+ FreePool (VarData);
return EFI_OUT_OF_RESOURCES;
}
@@ -1229,7 +1228,7 @@ Var_UpdateBBSOption (
NewOrder,
DevOrder->Length - sizeof (UINT16)
);
- SafeFreePool (NewOrder);
+ FreePool (NewOrder);
Status = gRT->SetVariable (
VAR_LEGACY_DEV_ORDER,
@@ -1239,7 +1238,7 @@ Var_UpdateBBSOption (
OriginalPtr
);
- SafeFreePool (OriginalPtr);
+ FreePool (OriginalPtr);
//
// Update Optional Data of Boot####
@@ -1371,8 +1370,8 @@ Var_UpdateBBSOption (
NewOptionPtr
);
- SafeFreePool (NewOptionPtr);
- SafeFreePool (BootOptionVar);
+ FreePool (NewOptionPtr);
+ FreePool (BootOptionVar);
}
BOpt_GetBootOptions (CallbackData);
diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
index c2540795cd..2743dd8d04 100644
--- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
+++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
@@ -795,7 +795,9 @@ ConPlatformMatchDevicePaths (
TempDevicePath1,
DevicePathInst
);
- SafeFreePool (TempDevicePath1);
+ if (TempDevicePath1 != NULL) {
+ FreePool (TempDevicePath1);
+ }
TempDevicePath1 = TempDevicePath2;
}
}
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index a57265ebd2..6a0aad5716 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -393,8 +393,8 @@ GraphicsConsoleControllerDriverStart (
PackageList = HiiLibPreparePackageList (1, &mFontPackageListGuid, Package);
Status = mHiiDatabase->NewPackageList (mHiiDatabase, PackageList, NULL, &(Private->HiiHandle));
ASSERT_EFI_ERROR (Status);
- SafeFreePool (PackageList);
- SafeFreePool (Package);
+ FreePool (PackageList);
+ FreePool (Package);
mFirstAccessFlag = FALSE;
}
@@ -1205,8 +1205,10 @@ GraphicsConsoleConOutTestString (
&Blt,
NULL
);
- SafeFreePool (Blt);
- Blt = NULL;
+ if (Blt != NULL) {
+ FreePool (Blt);
+ Blt = NULL;
+ }
Count++;
if (EFI_ERROR (Status)) {
@@ -1754,7 +1756,7 @@ DrawUnicodeWeightAtCursorN (
String = AllocateCopyPool ((Count + 1) * sizeof (CHAR16), UnicodeWeight);
if (String == NULL) {
- SafeFreePool (Blt);
+ FreePool (Blt);
return EFI_OUT_OF_RESOURCES;
}
//
@@ -1764,8 +1766,8 @@ DrawUnicodeWeightAtCursorN (
FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));
if (FontInfo == NULL) {
- SafeFreePool (Blt);
- SafeFreePool (String);
+ FreePool (Blt);
+ FreePool (String);
return EFI_OUT_OF_RESOURCES;
}
//
@@ -1803,8 +1805,8 @@ DrawUnicodeWeightAtCursorN (
Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
if (Blt->Image.Bitmap == NULL) {
- SafeFreePool (Blt);
- SafeFreePool (String);
+ FreePool (Blt);
+ FreePool (String);
return EFI_OUT_OF_RESOURCES;
}
@@ -1847,15 +1849,21 @@ DrawUnicodeWeightAtCursorN (
);
}
- SafeFreePool (RowInfoArray);
- SafeFreePool (Blt->Image.Bitmap);
+ FreePool (RowInfoArray);
+ FreePool (Blt->Image.Bitmap);
} else {
Status = EFI_UNSUPPORTED;
}
- SafeFreePool (Blt);
- SafeFreePool (String);
- SafeFreePool (FontInfo);
+ if (Blt != NULL) {
+ FreePool (Blt);
+ }
+ if (String != NULL) {
+ FreePool (String);
+ }
+ if (FontInfo != NULL) {
+ FreePool (FontInfo);
+ }
return Status;
}
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
index c36eb066e0..390f95a36e 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
@@ -70,5 +70,5 @@
[Depex]
- gEfiSimpleTextOutProtocolGuid AND gEfiHiiDatabaseProtocolGuid
+ gEfiSimpleTextOutProtocolGuid AND gEfiHiiDatabaseProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index 59c2b15109..aed93be1f0 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -127,13 +127,13 @@ GetDevicePath (
Length /= 2;
*DevicePath = (UINT8 *) AllocateZeroPool (Length);
if (*DevicePath == NULL) {
- SafeFreePool (DevicePathString);
+ FreePool (DevicePathString);
return EFI_OUT_OF_RESOURCES;
}
HexStringToBufInReverseOrder (*DevicePath, &Length, DevicePathString);
- SafeFreePool (DevicePathString);
+ FreePool (DevicePathString);
return EFI_SUCCESS;
@@ -202,7 +202,9 @@ ExportAllStorage (
);
}
if (EFI_ERROR (Status)) {
- SafeFreePool (HandleBuffer);
+ if (HandleBuffer != NULL) {
+ FreePool (HandleBuffer);
+ }
return Status;
}
@@ -219,8 +221,8 @@ ExportAllStorage (
Status = HiiExportPackageLists (HiiDatabase, HiiHandle, &BufferSize, HiiPackageList);
}
if (EFI_ERROR (Status)) {
- SafeFreePool (HandleBuffer);
- SafeFreePool (HiiPackageList);
+ FreePool (HandleBuffer);
+ FreePool (HiiPackageList);
return Status;
}
@@ -270,9 +272,9 @@ ExportAllStorage (
Status = HiiGetPackageListHandle (HiiDatabase, HiiHandle, &DriverHandle);
if (EFI_ERROR (Status)) {
- SafeFreePool (HandleBuffer);
- SafeFreePool (HiiPackageList);
- SafeFreePool (Storage);
+ FreePool (HandleBuffer);
+ FreePool (HiiPackageList);
+ FreePool (Storage);
return Status;
}
Storage->DriverHandle = DriverHandle;
@@ -305,10 +307,10 @@ ExportAllStorage (
}
}
- SafeFreePool (HiiPackageList);
+ FreePool (HiiPackageList);
}
- SafeFreePool (HandleBuffer);
+ FreePool (HandleBuffer);
return EFI_SUCCESS;
}
@@ -603,7 +605,9 @@ GetValueOfNumber (
Status = EFI_SUCCESS;
Exit:
- SafeFreePool (Str);
+ if (Str != NULL) {
+ FreePool (Str);
+ }
return Status;
}
@@ -738,7 +742,7 @@ HiiConfigRoutingExtractConfig (
//
Status = GetDevicePath (ConfigRequest, (UINT8 **) &DevicePath);
if (EFI_ERROR (Status)) {
- SafeFreePool (ConfigRequest);
+ FreePool (ConfigRequest);
return Status;
}
@@ -765,7 +769,7 @@ HiiConfigRoutingExtractConfig (
}
}
- SafeFreePool (DevicePath);
+ FreePool (DevicePath);
if (DriverHandle == NULL) {
//
@@ -773,7 +777,7 @@ HiiConfigRoutingExtractConfig (
// Set Progress to the 'G' in "GUID" of the routing header.
//
*Progress = StringPtr;
- SafeFreePool (ConfigRequest);
+ FreePool (ConfigRequest);
return EFI_NOT_FOUND;
}
@@ -802,7 +806,7 @@ HiiConfigRoutingExtractConfig (
for (TmpPtr = StringPtr; CompareMem (TmpPtr, AccessProgress, RemainSize) != 0; TmpPtr++);
*Progress = TmpPtr;
- SafeFreePool (ConfigRequest);
+ FreePool (ConfigRequest);
return Status;
}
@@ -812,9 +816,9 @@ HiiConfigRoutingExtractConfig (
ASSERT (*AccessProgress == 0);
Status = AppendToMultiString (Results, AccessResults);
ASSERT_EFI_ERROR (Status);
- SafeFreePool (AccessResults);
+ FreePool (AccessResults);
AccessResults = NULL;
- SafeFreePool (ConfigRequest);
+ FreePool (ConfigRequest);
ConfigRequest = NULL;
//
@@ -951,7 +955,7 @@ HiiConfigRoutingExportConfig (
ConfigRequest = (EFI_STRING) AllocateZeroPool (RequestSize);
if (ConfigRequest == NULL) {
- SafeFreePool (PathHdr);
+ FreePool (PathHdr);
return EFI_OUT_OF_RESOURCES;
}
@@ -997,7 +1001,7 @@ HiiConfigRoutingExportConfig (
StringPtr += StrLen (L"PATH=");
StrCpy (StringPtr, PathHdr);
- SafeFreePool (PathHdr);
+ FreePool (PathHdr);
PathHdr = NULL;
//
@@ -1021,6 +1025,8 @@ HiiConfigRoutingExportConfig (
);
ASSERT_EFI_ERROR (Status);
+ AccessProgress = NULL;
+ AccessResults = NULL;
Status = ConfigAccess->ExtractConfig (
ConfigAccess,
ConfigRequest,
@@ -1028,8 +1034,13 @@ HiiConfigRoutingExportConfig (
&AccessResults
);
if (EFI_ERROR (Status)) {
- SafeFreePool (ConfigRequest);
- SafeFreePool (AccessResults);
+ FreePool (ConfigRequest);
+ if (AccessProgress != NULL) {
+ FreePool (AccessProgress);
+ }
+ if (AccessResults != NULL) {
+ FreePool (AccessResults);
+ }
return EFI_INVALID_PARAMETER;
}
@@ -1039,9 +1050,9 @@ HiiConfigRoutingExportConfig (
ASSERT (*AccessProgress == 0);
Status = AppendToMultiString (Results, AccessResults);
ASSERT_EFI_ERROR (Status);
- SafeFreePool (AccessResults);
+ FreePool (AccessResults);
AccessResults = NULL;
- SafeFreePool (ConfigRequest);
+ FreePool (ConfigRequest);
ConfigRequest = NULL;
}
@@ -1057,8 +1068,8 @@ HiiConfigRoutingExportConfig (
HII_FORMSET_STORAGE_SIGNATURE
);
RemoveEntryList (&Storage->Entry);
- SafeFreePool (Storage->Name);
- SafeFreePool (Storage);
+ FreePool (Storage->Name);
+ FreePool (Storage);
}
return EFI_SUCCESS;
@@ -1173,7 +1184,7 @@ HiiConfigRoutingRouteConfig (
//
Status = GetDevicePath (ConfigResp, (UINT8 **) &DevicePath);
if (EFI_ERROR (Status)) {
- SafeFreePool (ConfigResp);
+ FreePool (ConfigResp);
return Status;
}
@@ -1200,7 +1211,7 @@ HiiConfigRoutingRouteConfig (
}
}
- SafeFreePool (DevicePath);
+ FreePool (DevicePath);
if (DriverHandle == NULL) {
//
@@ -1208,7 +1219,7 @@ HiiConfigRoutingRouteConfig (
// Set Progress to the 'G' in "GUID" of the routing header.
//
*Progress = StringPtr;
- SafeFreePool (ConfigResp);
+ FreePool (ConfigResp);
return EFI_NOT_FOUND;
}
@@ -1237,11 +1248,11 @@ HiiConfigRoutingRouteConfig (
for (TmpPtr = StringPtr; CompareMem (TmpPtr, AccessProgress, RemainSize) != 0; TmpPtr++);
*Progress = TmpPtr;
- SafeFreePool (ConfigResp);
+ FreePool (ConfigResp);
return Status;
}
- SafeFreePool (ConfigResp);
+ FreePool (ConfigResp);
ConfigResp = NULL;
//
@@ -1408,7 +1419,7 @@ HiiBlockToConfig (
TmpBuffer,
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)
);
- SafeFreePool (TmpBuffer);
+ FreePool (TmpBuffer);
StringPtr += Length;
if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {
@@ -1432,7 +1443,7 @@ HiiBlockToConfig (
TmpBuffer,
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)
);
- SafeFreePool (TmpBuffer);
+ FreePool (TmpBuffer);
StringPtr += Length;
if (*StringPtr != 0 && *StringPtr != L'&') {
@@ -1471,7 +1482,7 @@ HiiBlockToConfig (
ASSERT_EFI_ERROR (Status);
ToLower (ValueStr);
- SafeFreePool (Value);
+ FreePool (Value);
Value = NULL;
//
@@ -1493,8 +1504,8 @@ HiiBlockToConfig (
AppendToMultiString (Config, ConfigElement);
- SafeFreePool (ConfigElement);
- SafeFreePool (ValueStr);
+ FreePool (ConfigElement);
+ FreePool (ValueStr);
ConfigElement = NULL;
ValueStr = NULL;
@@ -1519,11 +1530,16 @@ HiiBlockToConfig (
return EFI_SUCCESS;
Exit:
-
- SafeFreePool (*Config);
- SafeFreePool (ValueStr);
- SafeFreePool (Value);
- SafeFreePool (ConfigElement);
+ FreePool (*Config);
+ if (ValueStr != NULL) {
+ FreePool (ValueStr);
+ }
+ if (Value != NULL) {
+ FreePool (Value);
+ }
+ if (ConfigElement) {
+ FreePool (ConfigElement);
+ }
return Status;
@@ -1658,7 +1674,7 @@ HiiConfigToBlock (
TmpBuffer,
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)
);
- SafeFreePool (TmpBuffer);
+ FreePool (TmpBuffer);
StringPtr += Length;
if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) {
@@ -1682,7 +1698,7 @@ HiiConfigToBlock (
TmpBuffer,
(((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN)
);
- SafeFreePool (TmpBuffer);
+ FreePool (TmpBuffer);
StringPtr += Length;
if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) {
@@ -1719,7 +1735,7 @@ HiiConfigToBlock (
CopyMem (Block + Offset, Value, Width);
*BlockSize = Offset + Width - 1;
- SafeFreePool (Value);
+ FreePool (Value);
Value = NULL;
//
@@ -1743,7 +1759,9 @@ HiiConfigToBlock (
Exit:
- SafeFreePool (Value);
+ if (Value != NULL) {
+ FreePool (Value);
+ }
return Status;
}
@@ -1983,11 +2001,21 @@ Exit:
}
}
- SafeFreePool (GuidStr);
- SafeFreePool (NameStr);
- SafeFreePool (PathStr);
- SafeFreePool (AltIdStr);
- SafeFreePool (Result);
+ if (GuidStr != NULL) {
+ FreePool (GuidStr);
+ }
+ if (NameStr != NULL) {
+ FreePool (NameStr);
+ }
+ if (PathStr != NULL) {
+ FreePool (PathStr);
+ }
+ if (AltIdStr != NULL) {
+ FreePool (AltIdStr);
+ }
+ if (Result != NULL) {
+ FreePool (Result);
+ }
return Status;
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index 2a6ec0dfec..5a37dd0ef3 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -58,7 +58,7 @@ GenerateHiiDatabaseRecord (
DatabaseRecord->PackageList = AllocateZeroPool (sizeof (HII_DATABASE_PACKAGE_LIST_INSTANCE));
if (DatabaseRecord->PackageList == NULL) {
- SafeFreePool (DatabaseRecord);
+ FreePool (DatabaseRecord);
return EFI_OUT_OF_RESOURCES;
}
@@ -78,8 +78,8 @@ GenerateHiiDatabaseRecord (
//
HiiHandle = (HII_HANDLE *) AllocateZeroPool (sizeof (HII_HANDLE));
if (HiiHandle == NULL) {
- SafeFreePool (DatabaseRecord->PackageList);
- SafeFreePool (DatabaseRecord);
+ FreePool (DatabaseRecord->PackageList);
+ FreePool (DatabaseRecord);
return EFI_OUT_OF_RESOURCES;
}
HiiHandle->Signature = HII_HANDLE_SIGNATURE;
@@ -340,8 +340,9 @@ InvokeRegisteredFunction (
}
}
- SafeFreePool (Buffer);
- Buffer = NULL;
+ if (Buffer != NULL) {
+ FreePool (Buffer);
+ }
return EFI_SUCCESS;
}
@@ -390,7 +391,7 @@ InsertGuidPackage (
}
GuidPackage->GuidPkg = (UINT8 *) AllocateZeroPool (PackageHeader.Length);
if (GuidPackage->GuidPkg == NULL) {
- SafeFreePool (GuidPackage);
+ FreePool (GuidPackage);
return EFI_OUT_OF_RESOURCES;
}
@@ -524,8 +525,8 @@ RemoveGuidPackages (
RemoveEntryList (&Package->GuidEntry);
CopyMem (&PackageHeader, Package->GuidPkg, sizeof (EFI_HII_PACKAGE_HEADER));
PackageList->PackageListHdr.PackageLength -= PackageHeader.Length;
- SafeFreePool (Package->GuidPkg);
- SafeFreePool (Package);
+ FreePool (Package->GuidPkg);
+ FreePool (Package);
}
return EFI_SUCCESS;
@@ -579,7 +580,7 @@ InsertFormPackage (
FormPackage->IfrData = (UINT8 *) AllocateZeroPool (PackageHeader.Length - sizeof (EFI_HII_PACKAGE_HEADER));
if (FormPackage->IfrData == NULL) {
- SafeFreePool (FormPackage);
+ FreePool (FormPackage);
return EFI_OUT_OF_RESOURCES;
}
@@ -738,8 +739,8 @@ RemoveFormPackages (
RemoveEntryList (&Package->IfrEntry);
PackageList->PackageListHdr.PackageLength -= Package->FormPkgHdr.Length;
- SafeFreePool (Package->IfrData);
- SafeFreePool (Package);
+ FreePool (Package->IfrData);
+ FreePool (Package);
}
@@ -809,11 +810,11 @@ InsertStringPackage (
for (Link = PackageList->StringPkgHdr.ForwardLink; Link != &PackageList->StringPkgHdr; Link = Link->ForwardLink) {
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
if (R8_EfiLibCompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
- SafeFreePool (Language);
+ FreePool (Language);
return EFI_UNSUPPORTED;
}
}
- SafeFreePool (Language);
+ FreePool (Language);
//
// Create a String package node
@@ -876,9 +877,15 @@ InsertStringPackage (
Error:
- SafeFreePool (StringPackage->StringBlock);
- SafeFreePool (StringPackage->StringPkgHdr);
- SafeFreePool (StringPackage);
+ if (StringPackage->StringBlock != NULL) {
+ FreePool (StringPackage->StringBlock);
+ }
+ if (StringPackage->StringPkgHdr != NULL) {
+ FreePool (StringPackage->StringPkgHdr);
+ }
+ if (StringPackage != NULL) {
+ FreePool (StringPackage);
+ }
return Status;
}
@@ -1014,8 +1021,8 @@ RemoveStringPackages (
RemoveEntryList (&Package->StringEntry);
PackageList->PackageListHdr.PackageLength -= Package->StringPkgHdr->Header.Length;
- SafeFreePool (Package->StringBlock);
- SafeFreePool (Package->StringPkgHdr);
+ FreePool (Package->StringBlock);
+ FreePool (Package->StringPkgHdr);
//
// Delete font information
//
@@ -1027,10 +1034,10 @@ RemoveStringPackages (
HII_FONT_INFO_SIGNATURE
);
RemoveEntryList (&FontInfo->Entry);
- SafeFreePool (FontInfo);
+ FreePool (FontInfo);
}
- SafeFreePool (Package);
+ FreePool (Package);
}
return EFI_SUCCESS;
@@ -1169,11 +1176,21 @@ InsertFontPackage (
Error:
- SafeFreePool (FontPkgHdr);
- SafeFreePool (FontInfo);
- SafeFreePool (FontPackage->GlyphBlock);
- SafeFreePool (FontPackage);
- SafeFreePool (GlobalFont);
+ if (FontPkgHdr != NULL) {
+ FreePool (FontPkgHdr);
+ }
+ if (FontInfo != NULL) {
+ FreePool (FontInfo);
+ }
+ if (FontPackage->GlyphBlock != NULL) {
+ FreePool (FontPackage->GlyphBlock);
+ }
+ if (FontPackage != NULL) {
+ FreePool (FontPackage);
+ }
+ if (GlobalFont != NULL) {
+ FreePool (GlobalFont);
+ }
return Status;
@@ -1313,8 +1330,11 @@ RemoveFontPackages (
RemoveEntryList (&Package->FontEntry);
PackageList->PackageListHdr.PackageLength -= Package->FontPkgHdr->Header.Length;
- SafeFreePool (Package->GlyphBlock);
- SafeFreePool (Package->FontPkgHdr);
+
+ if (Package->GlyphBlock != NULL) {
+ FreePool (Package->GlyphBlock);
+ }
+ FreePool (Package->FontPkgHdr);
//
// Delete default character cell information
//
@@ -1326,7 +1346,7 @@ RemoveFontPackages (
HII_GLYPH_INFO_SIGNATURE
);
RemoveEntryList (&GlyphInfo->Entry);
- SafeFreePool (GlyphInfo);
+ FreePool (GlyphInfo);
}
//
@@ -1336,13 +1356,13 @@ RemoveFontPackages (
GlobalFont = CR (Link, HII_GLOBAL_FONT_INFO, Entry, HII_GLOBAL_FONT_INFO_SIGNATURE);
if (GlobalFont->FontPackage == Package) {
RemoveEntryList (&GlobalFont->Entry);
- SafeFreePool (GlobalFont->FontInfo);
- SafeFreePool (GlobalFont);
+ FreePool (GlobalFont->FontInfo);
+ FreePool (GlobalFont);
break;
}
}
- SafeFreePool (Package);
+ FreePool (Package);
}
return EFI_SUCCESS;
@@ -1430,7 +1450,7 @@ InsertImagePackage (
ImagePackage->PaletteBlock = (UINT8 *) AllocateZeroPool (PaletteSize);
if (ImagePackage->PaletteBlock == NULL) {
- SafeFreePool (ImagePackage);
+ FreePool (ImagePackage);
return EFI_OUT_OF_RESOURCES;
}
CopyMem (
@@ -1450,8 +1470,8 @@ InsertImagePackage (
sizeof (EFI_HII_IMAGE_PACKAGE_HDR) - PaletteSize;
ImagePackage->ImageBlock = (UINT8 *) AllocateZeroPool (ImageSize);
if (ImagePackage->ImageBlock == NULL) {
- SafeFreePool (ImagePackage->PaletteBlock);
- SafeFreePool (ImagePackage);
+ FreePool (ImagePackage->PaletteBlock);
+ FreePool (ImagePackage);
return EFI_OUT_OF_RESOURCES;
}
CopyMem (
@@ -1611,9 +1631,11 @@ RemoveImagePackages (
PackageList->PackageListHdr.PackageLength -= Package->ImagePkgHdr.Header.Length;
- SafeFreePool (Package->ImageBlock);
- SafeFreePool (Package->PaletteBlock);
- SafeFreePool (Package);
+ FreePool (Package->ImageBlock);
+ if (Package->PaletteBlock != NULL) {
+ FreePool (Package->PaletteBlock);
+ }
+ FreePool (Package);
PackageList->ImagePkg = NULL;
@@ -1691,8 +1713,12 @@ InsertSimpleFontPackage (
Error:
- SafeFreePool (SimpleFontPackage->SimpleFontPkgHdr);
- SafeFreePool (SimpleFontPackage);
+ if (SimpleFontPackage->SimpleFontPkgHdr != NULL) {
+ FreePool (SimpleFontPackage->SimpleFontPkgHdr);
+ }
+ if (SimpleFontPackage != NULL) {
+ FreePool (SimpleFontPackage);
+ }
return Status;
}
@@ -1817,8 +1843,8 @@ RemoveSimpleFontPackages (
RemoveEntryList (&Package->SimpleFontEntry);
PackageList->PackageListHdr.PackageLength -= Package->SimpleFontPkgHdr->Header.Length;
- SafeFreePool (Package->SimpleFontPkgHdr);
- SafeFreePool (Package);
+ FreePool (Package->SimpleFontPkgHdr);
+ FreePool (Package);
}
return EFI_SUCCESS;
@@ -2003,7 +2029,7 @@ RemoveDevicePathPackage (
CopyMem (&Header, Package, sizeof (EFI_HII_PACKAGE_HEADER));
PackageList->PackageListHdr.PackageLength -= Header.Length;
- SafeFreePool (Package);
+ FreePool (Package);
PackageList->DevicePathPkg = NULL;
@@ -2132,8 +2158,12 @@ InsertKeyboardLayoutPackage (
Error:
- SafeFreePool (KeyboardLayoutPackage->KeyboardPkg);
- SafeFreePool (KeyboardLayoutPackage);
+ if (KeyboardLayoutPackage->KeyboardPkg != NULL) {
+ FreePool (KeyboardLayoutPackage->KeyboardPkg);
+ }
+ if (KeyboardLayoutPackage != NULL) {
+ FreePool (KeyboardLayoutPackage);
+ }
return Status;
}
@@ -2265,8 +2295,8 @@ RemoveKeyboardLayoutPackages (
RemoveEntryList (&Package->KeyboardEntry);
CopyMem (&PackageHeader, Package->KeyboardPkg, sizeof (EFI_HII_PACKAGE_HEADER));
PackageList->PackageListHdr.PackageLength -= PackageHeader.Length;
- SafeFreePool (Package->KeyboardPkg);
- SafeFreePool (Package);
+ FreePool (Package->KeyboardPkg);
+ FreePool (Package);
}
return EFI_SUCCESS;
@@ -2850,9 +2880,9 @@ HiiRemovePackageList (
ASSERT (Private->HiiHandleCount >= 0);
HiiHandle->Signature = 0;
- SafeFreePool (HiiHandle);
- SafeFreePool (Node->PackageList);
- SafeFreePool (Node);
+ FreePool (HiiHandle);
+ FreePool (Node->PackageList);
+ FreePool (Node);
return EFI_SUCCESS;
}
@@ -3387,8 +3417,7 @@ HiiUnregisterPackageNotify (
NULL
);
ASSERT_EFI_ERROR (Status);
- SafeFreePool (Notify);
- Notify = NULL;
+ FreePool (Notify);
return EFI_SUCCESS;
}
@@ -3670,7 +3699,9 @@ HiiSetKeyboardLayout (
// Backup current keyboard layout.
//
CopyMem (&Private->CurrentLayoutGuid, KeyGuid, sizeof (EFI_GUID));
- SafeFreePool(Private->CurrentLayout);
+ if (Private->CurrentLayout != NULL) {
+ FreePool(Private->CurrentLayout);
+ }
Private->CurrentLayout = KeyboardLayout;
//
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
index a9d9571f83..06b09e7f76 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
@@ -1024,7 +1024,9 @@ IsSystemFontInfo (
Exit:
if (SystemInfo == NULL) {
- SafeFreePool (SystemDefault);
+ if (SystemDefault != NULL) {
+ FreePool (SystemDefault);
+ }
}
return Flag;
}
@@ -1646,7 +1648,9 @@ HiiStringToImage (
Status = GetGlyphBuffer (Private, *StringPtr, FontInfo, &GlyphBuf[Index], &Cell[Index], &Attributes[Index]);
if (Status == EFI_NOT_FOUND) {
if ((Flags & EFI_HII_IGNORE_IF_NO_GLYPH) == EFI_HII_IGNORE_IF_NO_GLYPH) {
- SafeFreePool (GlyphBuf[Index]);
+ if (GlyphBuf[Index] != NULL) {
+ FreePool (GlyphBuf[Index]);
+ }
GlyphBuf[Index] = NULL;
StringPtr++;
} else {
@@ -1871,11 +1875,11 @@ HiiStringToImage (
0
);
if (EFI_ERROR (Status)) {
- SafeFreePool (BltBuffer);
+ FreePool (BltBuffer);
goto Exit;
}
- SafeFreePool (BltBuffer);
+ FreePool (BltBuffer);
} else {
for (Index1 = RowInfo[RowIndex].StartIndex; Index1 <= RowInfo[RowIndex].EndIndex; Index1++) {
@@ -1938,7 +1942,7 @@ HiiStringToImage (
Image->Height = 600;
Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height *sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
if (Image->Image.Bitmap == NULL) {
- SafeFreePool (Image);
+ FreePool (Image);
return EFI_OUT_OF_RESOURCES;
}
@@ -1970,16 +1974,34 @@ HiiStringToImage (
Exit:
for (Index = 0; Index < MAX_STRING_LENGTH; Index++) {
- SafeFreePool (GlyphBuf[Index]);
+ if (GlyphBuf[Index] != NULL) {
+ FreePool (GlyphBuf[Index]);
+ }
+ }
+ if (StringIn != NULL) {
+ FreePool (StringIn);
+ }
+ if (StringIn2 != NULL) {
+ FreePool (StringIn2);
+ }
+ if (StringInfoOut != NULL) {
+ FreePool (StringInfoOut);
+ }
+ if (RowInfo != NULL) {
+ FreePool (RowInfo);
+ }
+ if (SystemDefault != NULL) {
+ FreePool (SystemDefault);
+ }
+ if (GlyphBuf != NULL) {
+ FreePool (GlyphBuf);
+ }
+ if (Cell != NULL) {
+ FreePool (Cell);
+ }
+ if (Attributes != NULL) {
+ FreePool (Attributes);
}
- SafeFreePool (StringIn);
- SafeFreePool (StringIn2);
- SafeFreePool (StringInfoOut);
- SafeFreePool (RowInfo);
- SafeFreePool (SystemDefault);
- SafeFreePool (GlyphBuf);
- SafeFreePool (Cell);
- SafeFreePool (Attributes);
return Status;
}
@@ -2113,7 +2135,7 @@ HiiStringIdToImage (
&StringFontInfo
);
if (Status == EFI_BUFFER_TOO_SMALL) {
- SafeFreePool (String);
+ FreePool (String);
String = (EFI_STRING) AllocateZeroPool (StringSize);
if (String == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -2180,9 +2202,15 @@ HiiStringIdToImage (
);
Exit:
- SafeFreePool (String);
- SafeFreePool (StringFontInfo);
- SafeFreePool (NewStringInfo);
+ if (String != NULL) {
+ FreePool (String);
+ }
+ if (StringFontInfo != NULL) {
+ FreePool (StringFontInfo);
+ }
+ if (NewStringInfo != NULL) {
+ FreePool (NewStringInfo);
+ }
return Status;
}
@@ -2296,7 +2324,7 @@ HiiGetGlyph (
Image->Image.Bitmap = AllocateZeroPool (Image->Width * Image->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
if (Image->Image.Bitmap == NULL) {
- SafeFreePool (Image);
+ FreePool (Image);
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
@@ -2337,10 +2365,18 @@ Exit:
}
}
- SafeFreePool (SystemDefault);
- SafeFreePool (StringInfoOut);
- SafeFreePool (String);
- SafeFreePool (GlyphBuffer);
+ if (SystemDefault != NULL) {
+ FreePool (SystemDefault);
+ }
+ if (StringInfoOut != NULL) {
+ FreePool (StringInfoOut);
+ }
+ if (String != NULL) {
+ FreePool (String);
+ }
+ if (GlyphBuffer != NULL) {
+ FreePool (GlyphBuffer);
+ }
return Status;
}
@@ -2539,8 +2575,12 @@ Exit:
*FontHandle = LocalFontHandle;
}
- SafeFreePool (SystemDefault);
- SafeFreePool (FontInfo);
+ if (SystemDefault != NULL) {
+ FreePool (SystemDefault);
+ }
+ if (FontInfo != NULL) {
+ FreePool (FontInfo);
+ }
return Status;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index e570913c6f..dc543b80e1 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -288,7 +288,7 @@ Output1bitPixel (
ZeroMem (PaletteValue, sizeof (PaletteValue));
CopyRgbToGopPixel (&PaletteValue[0], &Palette->PaletteValue[0], 1);
CopyRgbToGopPixel (&PaletteValue[1], &Palette->PaletteValue[1], 1);
- SafeFreePool (Palette);
+ FreePool (Palette);
//
// Convert the pixel from one bit to corresponding color.
@@ -373,7 +373,7 @@ Output4bitPixel (
ZeroMem (PaletteValue, sizeof (PaletteValue));
CopyRgbToGopPixel (PaletteValue, Palette->PaletteValue, PaletteNum);
- SafeFreePool (Palette);
+ FreePool (Palette);
//
// Convert the pixel from 4 bit to corresponding color.
@@ -446,7 +446,7 @@ Output8bitPixel (
PaletteNum = (UINT16)(Palette->PaletteSize / sizeof (EFI_HII_RGB_PIXEL));
ZeroMem (PaletteValue, sizeof (PaletteValue));
CopyRgbToGopPixel (PaletteValue, Palette->PaletteValue, PaletteNum);
- SafeFreePool (Palette);
+ FreePool (Palette);
//
// Convert the pixel from 8 bits to corresponding color.
@@ -679,7 +679,7 @@ HiiNewImage (
ImagePackage->ImageBlock,
ImagePackage->ImageBlockSize - sizeof (EFI_HII_IIBT_END_BLOCK)
);
- SafeFreePool (ImagePackage->ImageBlock);
+ FreePool (ImagePackage->ImageBlock);
ImagePackage->ImageBlock = ImageBlock;
ImageBlock += ImagePackage->ImageBlockSize - sizeof (EFI_HII_IIBT_END_BLOCK);
//
@@ -687,8 +687,7 @@ HiiNewImage (
//
NewBlock = AllocateZeroPool (NewBlockSize);
if (NewBlock == NULL) {
- SafeFreePool (ImagePackage->ImageBlock);
- ImagePackage->ImageBlock = NULL;
+ FreePool (ImagePackage->ImageBlock);
return EFI_OUT_OF_RESOURCES;
}
NewBlockPtr = NewBlock;
@@ -735,7 +734,7 @@ HiiNewImage (
ImagePackage->ImageBlockSize = (UINT32) BlockSize;
ImagePackage->ImageBlock = (UINT8 *) AllocateZeroPool (BlockSize);
if (ImagePackage->ImageBlock == NULL) {
- SafeFreePool (ImagePackage);
+ FreePool (ImagePackage);
return EFI_OUT_OF_RESOURCES;
}
ImageBlock = ImagePackage->ImageBlock;
@@ -745,8 +744,8 @@ HiiNewImage (
//
NewBlock = AllocateZeroPool (NewBlockSize);
if (NewBlock == NULL) {
- SafeFreePool (ImagePackage->ImageBlock);
- SafeFreePool (ImagePackage);
+ FreePool (ImagePackage->ImageBlock);
+ FreePool (ImagePackage);
return EFI_OUT_OF_RESOURCES;
}
NewBlockPtr = NewBlock;
@@ -774,7 +773,7 @@ HiiNewImage (
CopyGopToRgbPixel ((EFI_HII_RGB_PIXEL *) NewBlock, ImageIn->Bitmap, ImageIn->Width * ImageIn->Height);
CopyMem (ImageBlock, NewBlockPtr, NewBlockSize);
- SafeFreePool (NewBlockPtr);
+ FreePool (NewBlockPtr);
//
// Append the block end
@@ -1156,7 +1155,7 @@ HiiSetImage (
BlockSize = ImagePackage->ImageBlockSize + NewBlockSize - OldBlockSize;
Block = (UINT8 *) AllocateZeroPool (BlockSize);
if (Block == NULL) {
- SafeFreePool (NewBlock);
+ FreePool (NewBlock);
return EFI_OUT_OF_RESOURCES;
}
@@ -1169,8 +1168,8 @@ HiiSetImage (
BlockPtr += NewBlockSize;
CopyMem (BlockPtr, ImageBlock + OldBlockSize, Part2Size);
- SafeFreePool (ImagePackage->ImageBlock);
- SafeFreePool (NewBlock);
+ FreePool (ImagePackage->ImageBlock);
+ FreePool (NewBlock);
ImagePackage->ImageBlock = Block;
ImagePackage->ImageBlockSize = BlockSize;
ImagePackage->ImagePkgHdr.Header.Length += NewBlockSize - OldBlockSize;
@@ -1366,7 +1365,7 @@ HiiDrawImage (
}
- SafeFreePool (BltBuffer);
+ FreePool (BltBuffer);
return Status;
} else {
@@ -1384,7 +1383,7 @@ HiiDrawImage (
ImageOut = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
if (ImageOut == NULL) {
- SafeFreePool (BltBuffer);
+ FreePool (BltBuffer);
return EFI_OUT_OF_RESOURCES;
}
ImageOut->Width = (UINT16) Width;
@@ -1397,14 +1396,14 @@ HiiDrawImage (
//
Status = GetSystemFont (Private, &FontInfo, NULL);
if (EFI_ERROR (Status)) {
- SafeFreePool (BltBuffer);
- SafeFreePool (ImageOut);
+ FreePool (BltBuffer);
+ FreePool (ImageOut);
return Status;
}
for (Index = 0; Index < Width * Height; Index++) {
BltBuffer[Index] = FontInfo->BackgroundColor;
}
- SafeFreePool (FontInfo);
+ FreePool (FontInfo);
//
// Draw the incoming image to the new created image.
@@ -1494,7 +1493,9 @@ HiiDrawImageId (
// Draw this image.
//
Status = HiiDrawImage (This, Flags, &Image, Blt, BltX, BltY);
- SafeFreePool (Image.Bitmap);
+ if (Image.Bitmap != NULL) {
+ FreePool (Image.Bitmap);
+ }
return Status;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c
index 57b887d8a6..d4fcc971e5 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c
@@ -511,7 +511,7 @@ FindStringBlock (
//
StringPackage->FontId++;
- SafeFreePool (FontInfo);
+ FreePool (FontInfo);
}
BlockSize += Ext2.Length;
@@ -814,7 +814,7 @@ SetStringWorker (
TmpSize
);
- SafeFreePool (StringPackage->StringBlock);
+ FreePool (StringPackage->StringBlock);
StringPackage->StringBlock = Block;
StringPackage->StringPkgHdr->Header.Length += (UINT32) (BlockSize - OldBlockSize);
break;
@@ -847,7 +847,7 @@ SetStringWorker (
OldBlockSize - (StringTextPtr - StringPackage->StringBlock) - StringSize
);
- SafeFreePool (StringPackage->StringBlock);
+ FreePool (StringPackage->StringBlock);
StringPackage->StringBlock = Block;
StringPackage->StringPkgHdr->Header.Length += (UINT32) (BlockSize - OldBlockSize);
break;
@@ -898,7 +898,7 @@ SetStringWorker (
CopyMem (BlockPtr, StringPackage->StringBlock, OldBlockSize);
- SafeFreePool (StringPackage->StringBlock);
+ FreePool (StringPackage->StringBlock);
StringPackage->StringBlock = Block;
StringPackage->StringPkgHdr->Header.Length += Ext2.Length;
@@ -1043,7 +1043,7 @@ HiiNewString (
HeaderSize = (UINT32) (AsciiStrSize ((CHAR8 *) Language) - 1 + sizeof (EFI_HII_STRING_PACKAGE_HDR));
StringPackage->StringPkgHdr = AllocateZeroPool (HeaderSize);
if (StringPackage->StringPkgHdr == NULL) {
- SafeFreePool (StringPackage);
+ FreePool (StringPackage);
return EFI_OUT_OF_RESOURCES;
}
StringPackage->StringPkgHdr->Header.Type = EFI_HII_PACKAGE_STRINGS;
@@ -1063,8 +1063,8 @@ HiiNewString (
BlockSize = Ucs2BlockSize + sizeof (EFI_HII_SIBT_END_BLOCK);
StringPackage->StringBlock = (UINT8 *) AllocateZeroPool (BlockSize);
if (StringPackage->StringBlock == NULL) {
- SafeFreePool (StringPackage->StringPkgHdr);
- SafeFreePool (StringPackage);
+ FreePool (StringPackage->StringPkgHdr);
+ FreePool (StringPackage);
return EFI_OUT_OF_RESOURCES;
}
@@ -1139,7 +1139,7 @@ HiiNewString (
// Append a EFI_HII_SIBT_END block to the end.
//
*BlockPtr = EFI_HII_SIBT_END;
- SafeFreePool (StringPackage->StringBlock);
+ FreePool (StringPackage->StringBlock);
StringPackage->StringBlock = StringBlock;
StringPackage->StringPkgHdr->Header.Length += Ucs2BlockSize;
PackageListNode->PackageListHdr.PackageLength += Ucs2BlockSize;
@@ -1180,7 +1180,7 @@ HiiNewString (
// Append a EFI_HII_SIBT_END block to the end.
//
*BlockPtr = EFI_HII_SIBT_END;
- SafeFreePool (StringPackage->StringBlock);
+ FreePool (StringPackage->StringBlock);
StringPackage->StringBlock = StringBlock;
StringPackage->StringPkgHdr->Header.Length += Ucs2FontBlockSize;
PackageListNode->PackageListHdr.PackageLength += Ucs2FontBlockSize;
@@ -1240,7 +1240,7 @@ HiiNewString (
// Append a EFI_HII_SIBT_END block to the end.
//
*BlockPtr = EFI_HII_SIBT_END;
- SafeFreePool (StringPackage->StringBlock);
+ FreePool (StringPackage->StringBlock);
StringPackage->StringBlock = StringBlock;
StringPackage->StringPkgHdr->Header.Length += FontBlockSize + Ucs2FontBlockSize;
PackageListNode->PackageListHdr.PackageLength += FontBlockSize + Ucs2FontBlockSize;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
index 25d4e0a678..46f70b986b 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
@@ -712,9 +712,15 @@ IfrCatenate (
Result->Value.string = NewString (StringPtr, FormSet->HiiHandle);
Done:
- SafeFreePool (String[0]);
- SafeFreePool (String[1]);
- SafeFreePool (StringPtr);
+ if (String[0] != NULL) {
+ FreePool (String[0]);
+ }
+ if (String[1] != NULL) {
+ FreePool (String[1]);
+ }
+ if (StringPtr != NULL) {
+ FreePool (StringPtr);
+ }
return Status;
}
@@ -770,8 +776,12 @@ IfrMatch (
Result->Value.b = mUnicodeCollation->MetaiMatch (mUnicodeCollation, String[0], String[1]);
Done:
- SafeFreePool (String[0]);
- SafeFreePool (String[1]);
+ if (String[0] != NULL) {
+ FreePool (String[0]);
+ }
+ if (String[1] != NULL) {
+ FreePool (String[1]);
+ }
return Status;
}
@@ -855,8 +865,12 @@ IfrFind (
}
Done:
- SafeFreePool (String[0]);
- SafeFreePool (String[1]);
+ if (String[0] != NULL) {
+ FreePool (String[0]);
+ }
+ if (String[1] != NULL) {
+ FreePool (String[1]);
+ }
return Status;
}
@@ -1025,8 +1039,12 @@ IfrToken (
Result->Value.string = NewString (SubString, FormSet->HiiHandle);
Done:
- SafeFreePool (String[0]);
- SafeFreePool (String[1]);
+ if (String[0] != NULL) {
+ FreePool (String[0]);
+ }
+ if (String[1] != NULL) {
+ FreePool (String[1]);
+ }
return Status;
}
@@ -1129,8 +1147,12 @@ IfrSpan (
Result->Value.u64 = StringPtr - String[1];
Done:
- SafeFreePool (String[0]);
- SafeFreePool (String[1]);
+ if (String[0] != NULL) {
+ FreePool (String[0]);
+ }
+ if (String[1] != NULL) {
+ FreePool (String[1]);
+ }
return Status;
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index 3a9a8bc3b9..f640d12e3a 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -445,7 +445,9 @@ DestroyExpression (
OpCode = EXPRESSION_OPCODE_FROM_LINK (Link);
RemoveEntryList (&OpCode->Link);
- SafeFreePool (OpCode->ValueList);
+ if (OpCode->ValueList != NULL) {
+ FreePool (OpCode->ValueList);
+ }
}
//
@@ -473,25 +475,41 @@ DestroyStorage (
return;
}
- SafeFreePool (Storage->Name);
- SafeFreePool (Storage->Buffer);
- SafeFreePool (Storage->EditBuffer);
+ if (Storage->Name != NULL) {
+ FreePool (Storage->Name);
+ }
+ if (Storage->Buffer != NULL) {
+ FreePool (Storage->Buffer);
+ }
+ if (Storage->EditBuffer != NULL) {
+ FreePool (Storage->EditBuffer);
+ }
while (!IsListEmpty (&Storage->NameValueListHead)) {
Link = GetFirstNode (&Storage->NameValueListHead);
NameValueNode = NAME_VALUE_NODE_FROM_LINK (Link);
RemoveEntryList (&NameValueNode->Link);
- SafeFreePool (NameValueNode->Name);
- SafeFreePool (NameValueNode->Value);
- SafeFreePool (NameValueNode->EditValue);
- SafeFreePool (NameValueNode);
+ if (NameValueNode->Name != NULL) {
+ FreePool (NameValueNode->Name);
+ }
+ if (NameValueNode->Value != NULL) {
+ FreePool (NameValueNode->Value);
+ }
+ if (NameValueNode->EditValue != NULL) {
+ FreePool (NameValueNode->EditValue);
+ }
+ FreePool (NameValueNode);
}
- SafeFreePool (Storage->ConfigHdr);
- SafeFreePool (Storage->ConfigRequest);
+ if (Storage->ConfigHdr != NULL) {
+ FreePool (Storage->ConfigHdr);
+ }
+ if (Storage->ConfigRequest != NULL) {
+ FreePool (Storage->ConfigRequest);
+ }
- gBS->FreePool (Storage);
+ FreePool (Storage);
}
@@ -555,8 +573,12 @@ DestroyStatement (
DestroyExpression (Expression);
}
- SafeFreePool (Statement->VariableName);
- SafeFreePool (Statement->BlockName);
+ if (Statement->VariableName != NULL) {
+ FreePool (Statement->VariableName);
+ }
+ if (Statement->BlockName != NULL) {
+ FreePool (Statement->BlockName);
+ }
}
@@ -623,7 +645,7 @@ DestroyFormSet (
//
// Free IFR binary buffer
//
- SafeFreePool (FormSet->IfrBinaryData);
+ FreePool (FormSet->IfrBinaryData);
//
// Free FormSet Storage
@@ -664,10 +686,14 @@ DestroyFormSet (
}
}
- SafeFreePool (FormSet->StatementBuffer);
- SafeFreePool (FormSet->ExpressionBuffer);
+ if (FormSet->StatementBuffer != NULL) {
+ FreePool (FormSet->StatementBuffer);
+ }
+ if (FormSet->ExpressionBuffer != NULL) {
+ FreePool (FormSet->ExpressionBuffer);
+ }
- SafeFreePool (FormSet);
+ FreePool (FormSet);
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
index 404bb31e10..ba6927c719 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
@@ -611,34 +611,34 @@ FreeBrowserStrings (
VOID
)
{
- SafeFreePool (gFunctionOneString);
- SafeFreePool (gFunctionTwoString);
- SafeFreePool (gFunctionNineString);
- SafeFreePool (gFunctionTenString);
- SafeFreePool (gEnterString);
- SafeFreePool (gEnterCommitString);
- SafeFreePool (gEscapeString);
- SafeFreePool (gMoveHighlight);
- SafeFreePool (gMakeSelection);
- SafeFreePool (gDecNumericInput);
- SafeFreePool (gHexNumericInput);
- SafeFreePool (gToggleCheckBox);
- SafeFreePool (gPromptForData);
- SafeFreePool (gPromptForPassword);
- SafeFreePool (gPromptForNewPassword);
- SafeFreePool (gConfirmPassword);
- SafeFreePool (gPassowordInvalid);
- SafeFreePool (gConfirmError);
- SafeFreePool (gPressEnter);
- SafeFreePool (gEmptyString);
- SafeFreePool (gAreYouSure);
- SafeFreePool (gYesResponse);
- SafeFreePool (gNoResponse);
- SafeFreePool (gMiniString);
- SafeFreePool (gPlusString);
- SafeFreePool (gMinusString);
- SafeFreePool (gAdjustNumber);
- SafeFreePool (gSaveChanges);
+ FreePool (gFunctionOneString);
+ FreePool (gFunctionTwoString);
+ FreePool (gFunctionNineString);
+ FreePool (gFunctionTenString);
+ FreePool (gEnterString);
+ FreePool (gEnterCommitString);
+ FreePool (gEscapeString);
+ FreePool (gMoveHighlight);
+ FreePool (gMakeSelection);
+ FreePool (gDecNumericInput);
+ FreePool (gHexNumericInput);
+ FreePool (gToggleCheckBox);
+ FreePool (gPromptForData);
+ FreePool (gPromptForPassword);
+ FreePool (gPromptForNewPassword);
+ FreePool (gConfirmPassword);
+ FreePool (gPassowordInvalid);
+ FreePool (gConfirmError);
+ FreePool (gPressEnter);
+ FreePool (gEmptyString);
+ FreePool (gAreYouSure);
+ FreePool (gYesResponse);
+ FreePool (gNoResponse);
+ FreePool (gMiniString);
+ FreePool (gPlusString);
+ FreePool (gMinusString);
+ FreePool (gAdjustNumber);
+ FreePool (gSaveChanges);
return ;
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index f728d53910..29b606fdef 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -724,7 +724,9 @@ NewStringCpy (
IN CHAR16 *Src
)
{
- SafeFreePool (*Dest);
+ if (*Dest != NULL) {
+ FreePool (*Dest);
+ }
*Dest = AllocateCopyPool (StrSize (Src), Src);
ASSERT (*Dest != NULL);
}
@@ -865,7 +867,9 @@ SetValueByName (
Node = NAME_VALUE_NODE_FROM_LINK (Link);
if (StrCmp (Name, Node->Name) == 0) {
- SafeFreePool (Node->EditValue);
+ if (Node->EditValue != NULL) {
+ FreePool (Node->EditValue);
+ }
Node->EditValue = AllocateCopyPool (StrSize (Value), Value);
ASSERT (Node->EditValue != NULL);
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
index 8421ad9777..390d551386 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
@@ -2137,7 +2137,9 @@ UiDisplayMenu (
gDirection = SCAN_LEFT;
}
Status = ProcessOptions (Selection, MenuOption, TRUE, &OptionString);
- SafeFreePool (OptionString);
+ if (OptionString != NULL) {
+ FreePool (OptionString);
+ }
}
break;