From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (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 A70EB20945D8D for ; Tue, 8 May 2018 19:32:19 -0700 (PDT) Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Wed, 09 May 2018 04:32:17 +0200 Received: from GaryWorkstation (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Wed, 09 May 2018 03:31:48 +0100 Date: Wed, 9 May 2018 10:31:44 +0800 From: Gary Lin To: Dandan Bi Cc: edk2-devel@lists.01.org, Eric Dong , Liming Gao Message-ID: <20180509023144.n2iwuwlunwnmwv45@GaryWorkstation> References: <20180508114620.78328-1-dandan.bi@intel.com> MIME-Version: 1.0 In-Reply-To: <20180508114620.78328-1-dandan.bi@intel.com> User-Agent: NeoMutt/20170912 (1.9.0) Subject: Re: [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: Wed, 09 May 2018 02:32:20 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 08, 2018 at 07:46:19PM +0800, Dandan Bi wrote: > _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 --; An extra space was added. > } > >> > ; > > // > @@ -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 ( > -- I applied the patch and triggered the rebuild of ovmf. It's now built on all versions and arch. Thanks for fixing it. Tested-by: Gary Lin > 2.14.3.windows.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >