summaryrefslogtreecommitdiff
path: root/edk2/StdLib/LibC
diff options
context:
space:
mode:
authordarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2012-09-24 22:44:03 +0000
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>2012-09-24 22:44:03 +0000
commit24a6108c898f90f8006a48ce37ac6710f129bcbf (patch)
tree2f856bcd73fd33e5184a32c748d589428bcf72f4 /edk2/StdLib/LibC
parent49e64bf454be93f4496e728dddff550e5ab79182 (diff)
StdLib/LibC/StdLib/Malloc.c: Make the free() function conform to the ISO/IEC 9899 (C95) specification.
The C95 specification states: "The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs". The UEFI FreePool() function, which the StdLib implementation of free() uses, does not make this check. This fix adds a check for null to the free() function such that if the pointer argument is NULL, nothing is done. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: erik.c.bjorge@intel.com git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@13739 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'edk2/StdLib/LibC')
-rw-r--r--edk2/StdLib/LibC/StdLib/Malloc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/edk2/StdLib/LibC/StdLib/Malloc.c b/edk2/StdLib/LibC/StdLib/Malloc.c
index 51068d3a0..3f79deb49 100644
--- a/edk2/StdLib/LibC/StdLib/Malloc.c
+++ b/edk2/StdLib/LibC/StdLib/Malloc.c
@@ -137,7 +137,9 @@ calloc(size_t Num, size_t Size)
void
free(void *Ptr)
{
- (void) gBS->FreePool (Ptr);
+ if(Ptr != NULL) {
+ (void) gBS->FreePool (Ptr);
+ }
}
/** The realloc function changes the size of the object pointed to by Ptr to