]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c
CryptoPkg: RuntimeCryptLib: support free(NULL)
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / SysCall / RuntimeMemAllocation.c
index 616ee7717e72859b993da72b37d939dff00c1e5a..45ef9ff5f2525a48f7dbf8c7e52202cc09a1dbdd 100644 (file)
@@ -434,5 +434,11 @@ void *realloc (void *ptr, size_t size)
 /* Deallocates or frees a memory block */\r
 void free (void *ptr)\r
 {\r
-  RuntimeFreeMem (ptr);\r
+  //\r
+  // In Standard C, free() handles a null pointer argument transparently. This\r
+  // is not true of RuntimeFreeMem() below, so protect it.\r
+  //\r
+  if (ptr != NULL) {\r
+    RuntimeFreeMem (ptr);\r
+  }\r
 }\r