From: Dandan Bi Date: Wed, 6 Jan 2016 00:57:23 +0000 (+0000) Subject: MdeModulePkg:Fix the potential memory leak issue in Display Engine X-Git-Tag: edk2-stable201903~8101 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=b954a4fe01f3477d28eaf575dd36a9015e315aca MdeModulePkg:Fix the potential memory leak issue in Display Engine 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 Reviewed-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19593 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c index a391442d16..66f7dffc53 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c @@ -3729,6 +3729,35 @@ UiDisplayMenu ( } } +/** + Free the UI Menu Option structure data. + + @param MenuOptionList Point to the menu option list which need to be free. + +**/ + +VOID +FreeMenuOptionData( + LIST_ENTRY *MenuOptionList + ) +{ + LIST_ENTRY *Link; + UI_MENU_OPTION *Option; + + // + // Free menu option list + // + while (!IsListEmpty (MenuOptionList)) { + Link = GetFirstNode (MenuOptionList); + Option = MENU_OPTION_FROM_LINK (Link); + if (Option->Description != NULL){ + FreePool(Option->Description); + } + RemoveEntryList (&Option->Link); + FreePool (Option); + } +} + /** Base on the browser status info to show an pop up message. @@ -4001,6 +4030,11 @@ FormDisplay ( CopyGuid (&gOldFormEntry.FormSetGuid, &FormData->FormSetGuid); gOldFormEntry.FormId = FormData->FormId; + // + //Free the Ui menu option list. + // + FreeMenuOptionData(&gMenuOption); + return Status; }