From: Dandan Bi Date: Wed, 7 Nov 2018 08:14:22 +0000 (+0800) Subject: MdeModulePkg/DisplayEngine: Remove useless NULL ptr check for NewPos X-Git-Tag: edk2-stable201903~629 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=8cd4e734ccdfbc961c72aeaa8dbd3f5154171f9b MdeModulePkg/DisplayEngine: Remove useless NULL ptr check for NewPos In function UiDisplayMenu, the NewPos ptr which used to point to the highlight menu entry. It will always point to the menu entry which need to be highlighted or the gMenuOption menu if the highlight menu is not found. So we can remove the NULL ptr check for NewPos in this function. And add the ASSERT code to avoid if any false positive reports of NULL pointer dereference issue raised from static analysis. Cc: Liming Gao Cc: Eric Dong Cc: Star Zeng Cc: Hao Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Star Zeng Reviewed-by: Liming Gao --- diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c index 7390f954b6..44f087fe01 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c @@ -2882,6 +2882,7 @@ UiDisplayMenu ( // ControlFlag = CfUpdateHelpString; + ASSERT (NewPos != NULL); UpdateHighlightMenuInfo(NewPos, TopOfScreen, SkipValue); if (SkipHighLight) { @@ -2910,7 +2911,7 @@ UiDisplayMenu ( Temp2 = 0; } - if (NewPos != NULL && (MenuOption == NULL || NewPos != &MenuOption->Link)) { + if (MenuOption == NULL || NewPos != &MenuOption->Link) { if (MenuOption != NULL) { // // Remove the old highlight menu.