]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg:Fix the potential memory leak issue in Display Engine
authorDandan Bi <dandan.bi@intel.com>
Wed, 6 Jan 2016 00:57:23 +0000 (00:57 +0000)
committerdandanbi <dandanbi@Edk2>
Wed, 6 Jan 2016 00:57:23 +0000 (00:57 +0000)
The MenuOption insert to gMenuOption allocate memory everytime,but not free.
Now add the code to free it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19593 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c

index a391442d169ac02e3d175b7046aeb38574cb2efc..66f7dffc537d7a173bd5289e61554329f27e460d 100644 (file)
@@ -3729,6 +3729,35 @@ UiDisplayMenu (
   }\r
 }\r
 \r
+/**\r
+  Free the UI Menu Option structure data.\r
+\r
+  @param   MenuOptionList         Point to the menu option list which need to be free.\r
+\r
+**/\r
+\r
+VOID\r
+FreeMenuOptionData(\r
+  LIST_ENTRY           *MenuOptionList\r
+  )\r
+{\r
+  LIST_ENTRY           *Link;\r
+  UI_MENU_OPTION       *Option;\r
+\r
+  //\r
+  // Free menu option list\r
+  //\r
+  while (!IsListEmpty (MenuOptionList)) {\r
+    Link = GetFirstNode (MenuOptionList);\r
+    Option = MENU_OPTION_FROM_LINK (Link);\r
+    if (Option->Description != NULL){\r
+      FreePool(Option->Description);\r
+    }\r
+    RemoveEntryList (&Option->Link);\r
+    FreePool (Option);\r
+  }\r
+}\r
+\r
 /**\r
 \r
   Base on the browser status info to show an pop up message.\r
@@ -4001,6 +4030,11 @@ FormDisplay (
   CopyGuid (&gOldFormEntry.FormSetGuid, &FormData->FormSetGuid);\r
   gOldFormEntry.FormId    = FormData->FormId;\r
 \r
+  //\r
+  //Free the Ui menu option list.\r
+  //\r
+  FreeMenuOptionData(&gMenuOption);\r
+\r
   return Status;\r
 }\r
 \r