]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/SysCall/BaseMemAllocation.c
CryptoPkg: BaseCryptLib: support free(NULL)
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / SysCall / BaseMemAllocation.c
index 544f07215b8f1b5dbdd89a1a233b822cf3634aae..964545f143cc5e45df4f397f3129a6da95aa21ff 100644 (file)
@@ -38,5 +38,11 @@ void *realloc (void *ptr, size_t size)
 /* De-allocates or frees a memory block */\r
 void free (void *ptr)\r
 {\r
-  FreePool (ptr);\r
+  //\r
+  // In Standard C, free() handles a null pointer argument transparently. This\r
+  // is not true of FreePool() below, so protect it.\r
+  //\r
+  if (ptr != NULL) {\r
+    FreePool (ptr);\r
+  }\r
 }\r