From: Laszlo Ersek Date: Wed, 24 Feb 2016 20:00:04 +0000 (+0100) Subject: CryptoPkg: RuntimeCryptLib: support realloc(NULL, size) X-Git-Tag: edk2-stable201903~7795 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=e89d672110aaf1c5a85404375ca6767b099d3b50 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 Cc: Qin Long Cc: Ting Ye Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Qin Long --- diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c b/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c index 45ef9ff5f2..413e47e923 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c @@ -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 //