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.

Cc: Liming Gao <[email protected]>
Cc: Eric Dong <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <[email protected]>
---
 MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c 
b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
index 9714dbc..98c81db 100644
--- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
+++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
@@ -300,11 +300,13 @@ LibDestroyMenuEntry (
   FILE_CONTEXT           *FileContext;
 
   FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext;
 
   if (!FileContext->IsRoot) {
-    FreePool (FileContext->DevicePath);
+    if (FileContext->DevicePath != NULL) {
+      FreePool (FileContext->DevicePath);
+    }
   } else {
     if (FileContext->FileHandle != NULL) {
       FileContext->FileHandle->Close (FileContext->FileHandle);
     }
   }
@@ -313,11 +315,13 @@ LibDestroyMenuEntry (
     FreePool (FileContext->FileName);
   }
 
   FreePool (FileContext);
 
-  FreePool (MenuEntry->DisplayString);
+  if (MenuEntry->DisplayString != NULL) {
+    FreePool (MenuEntry->DisplayString);
+  }
   if (MenuEntry->HelpString != NULL) {
     FreePool (MenuEntry->HelpString);
   }
 
   FreePool (MenuEntry);
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to