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 <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
This commit is contained in:
Dandan Bi 2016-01-06 00:57:23 +00:00 committed by dandanbi
parent 8339166dd1
commit b954a4fe01
1 changed files with 34 additions and 0 deletions

View File

@ -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;
}