]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: FileExplorerLib: Add check when to call FreePool function
authorDandan Bi <dandan.bi@intel.com>
Mon, 29 Feb 2016 02:08:47 +0000 (10:08 +0800)
committerFeng Tian <feng.tian@intel.com>
Wed, 2 Mar 2016 04:10:15 +0000 (12:10 +0800)
when free up resource allocated for a MenuEntry, there exists
the case that the DevicePath and DisplayString are NULL,
so before calling FreePool function, need to check.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
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