From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 30612207E36CB for ; Tue, 8 May 2018 04:46:30 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2018 04:46:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,378,1520924400"; d="scan'208";a="39580086" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 08 May 2018 04:46:29 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Liming Gao Date: Tue, 8 May 2018 19:46:19 +0800 Message-Id: <20180508114620.78328-1-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [patch] BaseTools/VfrCompile: Avoid using uninitialized pointer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2018 11:46:31 -0000 _CLEAR_SAVED_OPHDR () is used for initialize the variables. We should not update it to free memory. It will cause some pointer used before initialization. This patch is to fix this issue. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 4b0a43606ea..cc042ab4307 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -4103,12 +4103,15 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] : } } } if ($RootLevel == 0) { - _CLEAR_SAVED_OPHDR (); - mCIfrOpHdrIndex --; + if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) { + delete mCIfrOpHdr[mCIfrOpHdrIndex]; + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; + } + mCIfrOpHdrIndex --; } >> ; // @@ -5082,14 +5085,11 @@ EfiVfrParser::_SAVE_OPHDR_COND ( VOID EfiVfrParser::_CLEAR_SAVED_OPHDR ( VOID ) { - if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) { - delete mCIfrOpHdr[mCIfrOpHdrIndex]; - mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; - } + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; } BOOLEAN EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( -- 2.14.3.windows.1