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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user