mirror of https://github.com/acidanthera/audk.git
CryptoPkg: RuntimeCryptLib: support free(NULL)
The ISO C standard says about free(), If ptr is a null pointer, no action occurs. This is not true of the RuntimeFreeMem() internal function. Therefore we must not forward the argument of free() to RuntimeFreeMem() without checking. Cc: David Woodhouse <dwmw2@infradead.org> Cc: Qin Long <qin.long@intel.com> Cc: Ting Ye <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Qin Long <qin.long@intel.com>
This commit is contained in:
parent
211372d63a
commit
1246dde58e
|
@ -434,5 +434,11 @@ void *realloc (void *ptr, size_t size)
|
|||
/* Deallocates or frees a memory block */
|
||||
void free (void *ptr)
|
||||
{
|
||||
RuntimeFreeMem (ptr);
|
||||
//
|
||||
// In Standard C, free() handles a null pointer argument transparently. This
|
||||
// is not true of RuntimeFreeMem() below, so protect it.
|
||||
//
|
||||
if (ptr != NULL) {
|
||||
RuntimeFreeMem (ptr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue