From 676df92c2c0c5bdeb0f8e27349f5dd467928ce09 Mon Sep 17 00:00:00 2001 From: qwang12 Date: Thu, 30 Oct 2008 07:32:46 +0000 Subject: 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 --- .../Universal/Console/ConPlatformDxe/ConPlatform.c | 4 ++- .../Console/GraphicsConsoleDxe/GraphicsConsole.c | 36 +++++++++++++--------- 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'MdeModulePkg/Universal/Console') 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; } -- cgit v1.2.3