diff options
author | Laszlo Ersek <lersek@redhat.com> | 2016-02-24 21:00:04 +0100 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-02-26 09:44:16 +0800 |
commit | 34791faedd6449762fb9110151f70c7ef3713fd0 (patch) | |
tree | 02b6a9086cb530f40a7da69a7e236c613e1c09b7 | |
parent | 547b9e2744c4b18de4e5af62756e865a175c7e36 (diff) | |
download | edk2-platforms-34791faedd6449762fb9110151f70c7ef3713fd0.tar.xz |
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>
(cherry picked from commit e89d672110aaf1c5a85404375ca6767b099d3b50)
-rw-r--r-- | CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c | 4 |
1 files changed, 4 insertions, 0 deletions
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
//
|