CryptoPkg: RuntimeCryptLib: support realloc(NULL, size)

The ISO C standard says about realloc(),

  If ptr is a null pointer, the realloc function behaves like the malloc
  function for the specified size.

The realloc() implementation doesn't conform to this currently, so add a
check and call malloc() if appropriate.

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:
Laszlo Ersek 2016-02-24 21:00:04 +01:00
parent 1246dde58e
commit e89d672110
1 changed files with 4 additions and 0 deletions

View File

@ -396,6 +396,10 @@ void *realloc (void *ptr, size_t size)
UINTN StartPageIndex;
UINTN PageCount;
if (ptr == NULL) {
return malloc (size);
}
//
// Get Original Size of ptr
//