From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 53CBB2118847D for ; Wed, 7 Nov 2018 06:53:22 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2018 06:53:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,475,1534834800"; d="scan'208";a="279102602" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga006.fm.intel.com with ESMTP; 07 Nov 2018 06:53:20 -0800 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Liming Gao , Eric Dong , Star Zeng , Hao Wu Date: Wed, 7 Nov 2018 22:53:11 +0800 Message-Id: <20181107145311.42488-1-dandan.bi@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 Subject: [patch] MdeModulePkg/DisplayEngine: Remove useless NULL ptr check for NewPos X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Nov 2018 14:53:22 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1306 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 --- MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 @@ -2880,10 +2880,11 @@ UiDisplayMenu ( // MenuOption is set to NULL in Repaint // NewPos: Current menu option that need to hilight // ControlFlag = CfUpdateHelpString; + ASSERT (NewPos != NULL); UpdateHighlightMenuInfo(NewPos, TopOfScreen, SkipValue); if (SkipHighLight) { SkipHighLight = FALSE; MenuOption = SavedMenuOption; @@ -2908,11 +2909,11 @@ UiDisplayMenu ( Temp2 = SkipValue; } else { Temp2 = 0; } - if (NewPos != NULL && (MenuOption == NULL || NewPos != &MenuOption->Link)) { + if (MenuOption == NULL || NewPos != &MenuOption->Link) { if (MenuOption != NULL) { // // Remove the old highlight menu. // Status = DisplayOneMenu (MenuOption, -- 2.18.0.windows.1