]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg: RuntimeCryptLib: support realloc(NULL, size)
authorLaszlo Ersek <lersek@redhat.com>
Wed, 24 Feb 2016 20:00:04 +0000 (21:00 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 25 Feb 2016 10:04:31 +0000 (11:04 +0100)
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>
CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c

index 45ef9ff5f2525a48f7dbf8c7e52202cc09a1dbdd..413e47e9232542b1dfe9afde75fe869afee3d3d7 100644 (file)
@@ -396,6 +396,10 @@ void *realloc (void *ptr, size_t size)
   UINTN  StartPageIndex;\r
   UINTN  PageCount;\r
 \r
   UINTN  StartPageIndex;\r
   UINTN  PageCount;\r
 \r
+  if (ptr == NULL) {\r
+    return malloc (size);\r
+  }\r
+\r
   //\r
   // Get Original Size of ptr\r
   //\r
   //\r
   // Get Original Size of ptr\r
   //\r