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.126; helo=mga18.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 004D12096AECB for ; Tue, 8 May 2018 22:09:46 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2018 22:09:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,380,1520924400"; d="scan'208";a="37914334" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga007.fm.intel.com with ESMTP; 08 May 2018 22:09:45 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 8 May 2018 22:09:45 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 8 May 2018 22:09:45 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.79]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.6]) with mapi id 14.03.0319.002; Wed, 9 May 2018 13:09:43 +0800 From: "Bi, Dandan" To: Gary Lin CC: "edk2-devel@lists.01.org" , "Dong, Eric" , "Gao, Liming" Thread-Topic: [edk2] [patch] BaseTools/VfrCompile: Avoid using uninitialized pointer Thread-Index: AQHT5sJEL/yE07kZx02Eyq7LeHYprqQmKBwAgACw31A= Date: Wed, 9 May 2018 05:09:43 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB3BAD17B1@shsmsx102.ccr.corp.intel.com> References: <20180508114620.78328-1-dandan.bi@intel.com> <20180509023144.n2iwuwlunwnmwv45@GaryWorkstation> In-Reply-To: <20180509023144.n2iwuwlunwnmwv45@GaryWorkstation> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.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 05:09:47 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks for your test work.=20 I have created a V2 patch which make the code logic more clean. Would you m= ind to try the V2 patch in your environment? Thanks, Dandan -----Original Message----- From: Gary Lin [mailto:glin@suse.com]=20 Sent: Wednesday, May 9, 2018 10:32 AM To: Bi, Dandan Cc: edk2-devel@lists.01.org; Dong, Eric ; Gao, Liming = Subject: Re: [edk2] [patch] BaseTools/VfrCompile: Avoid using uninitialized= pointer 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. >=20 > 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(-) >=20 > diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g=20 > 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 =3D 0] : > } > } > } > =20 > if ($RootLevel= =3D=3D 0) { > - _CLEAR_SAVED= _OPHDR (); > - mCIfrOpHdrIn= dex --; > + if (mCIfrOpH= dr[mCIfrOpHdrIndex] !=3D NULL) { > + delete mCI= frOpHdr[mCIfrOpHdrIndex]; > + mCIfrOpHdr= [mCIfrOpHdrIndex] =3D NULL; > + } > + =20 > + mCIfrOpHdrIndex --; An extra space was added. > } > >> > ; > =20 > // > @@ -5082,14 +5085,11 @@ EfiVfrParser::_SAVE_OPHDR_COND ( VOID =20 > EfiVfrParser::_CLEAR_SAVED_OPHDR ( > VOID > ) > { > - if (mCIfrOpHdr[mCIfrOpHdrIndex] !=3D NULL) { > - delete mCIfrOpHdr[mCIfrOpHdrIndex]; > - mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; > - } > + mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; > mCIfrOpHdrLineNo[mCIfrOpHdrIndex] =3D 0; } > =20 > BOOLEAN > EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( > -- I applied the patch and triggered the rebuild of ovmf. It's now built on al= l versions and arch. Thanks for fixing it. Tested-by: Gary Lin > 2.14.3.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >=20