]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
MdeModulePkg: FileExplorerLib: Add check when to call FreePool function
[mirror_edk2.git] / MdeModulePkg / Library / FileExplorerLib / FileExplorer.c
index 9714dbcf5d24d52bc77a54d1999690052f57a7bd..98c81dbef9e5b46e7f7519b2a819e0b434cfebf6 100644 (file)
@@ -302,7 +302,9 @@ LibDestroyMenuEntry (
   FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext;\r
 \r
   if (!FileContext->IsRoot) {\r
-    FreePool (FileContext->DevicePath);\r
+    if (FileContext->DevicePath != NULL) {\r
+      FreePool (FileContext->DevicePath);\r
+    }\r
   } else {\r
     if (FileContext->FileHandle != NULL) {\r
       FileContext->FileHandle->Close (FileContext->FileHandle);\r
@@ -315,7 +317,9 @@ LibDestroyMenuEntry (
 \r
   FreePool (FileContext);\r
 \r
-  FreePool (MenuEntry->DisplayString);\r
+  if (MenuEntry->DisplayString != NULL) {\r
+    FreePool (MenuEntry->DisplayString);\r
+  }\r
   if (MenuEntry->HelpString != NULL) {\r
     FreePool (MenuEntry->HelpString);\r
   }\r