summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
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/HiiDatabaseDxe/Font.c
parentbb1d8ee66943c3d126abbfc007159eb0fe458927 (diff)
downloadedk2-676df92c2c0c5bdeb0f8e27349f5dd467928ce09.tar.gz
edk2-676df92c2c0c5bdeb0f8e27349f5dd467928ce09.tar.bz2
edk2-676df92c2c0c5bdeb0f8e27349f5dd467928ce09.zip
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/HiiDatabaseDxe/Font.c')
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Font.c90
1 files changed, 65 insertions, 25 deletions
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;
}