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.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 2576820348634 for ; Wed, 9 May 2018 20:34:31 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 20:34:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,383,1520924400"; d="scan'208";a="49670220" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 09 May 2018 20:34:30 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 9 May 2018 20:34:29 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 9 May 2018 20:34:29 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.240]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.210]) with mapi id 14.03.0319.002; Thu, 10 May 2018 11:34:28 +0800 From: "Ni, Ruiyu" To: Gary Lin , "Bi, Dandan" CC: "edk2-devel@lists.01.org" , "Dong, Eric" , "Gao, Liming" Thread-Topic: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer Thread-Index: AQHT51L5islz8eTbtEGq1EmbXHVxMqQmiFOAgAHIY+A= Date: Thu, 10 May 2018 03:34:27 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BC8DDCB@SHSMSX104.ccr.corp.intel.com> References: <20180509050211.76104-1-dandan.bi@intel.com> <20180509082009.uotkzgubbm2qtg2b@GaryWorkstation> In-Reply-To: <20180509082009.uotkzgubbm2qtg2b@GaryWorkstation> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch v2] 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: Thu, 10 May 2018 03:34:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Dandan, Can you describe the build failure met by Gary Lin in final commit message? The current commit message is not very clear about which issue it may fix. Thanks/Ray > -----Original Message----- > From: edk2-devel On Behalf Of Gary Lin > Sent: Wednesday, May 9, 2018 4:20 PM > To: Bi, Dandan > Cc: edk2-devel@lists.01.org; Dong, Eric ; Gao, Limin= g > > Subject: Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using > uninitialized pointer >=20 > On Wed, May 09, 2018 at 01:02:11PM +0800, Dandan Bi wrote: > > V2: > > Add function _INIT_OPHDR_COND () for variable initialization. > > Make code logic more clean. > > > > Previously _CLEAR_SAVED_OPHDR () is used for variable initialization, > > and we updated it to clean memory. > > But _CLEAR_SAVED_OPHDR () is still called for variable initialization. > > This will cause uninitialized pointer will be checked to free and > > cause unexpected issue. > > > > This patch is to add new function for variable initialization and keep > > _CLEAR_SAVED_OPHDR () to clean memory which is aligned with its > > function name. > > > This patch fixes the build errors I had :) >=20 > Tested-by: Gary Lin >=20 > > Cc: Eric Dong > > Cc: Liming Gao > > Cc: Gary Lin > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Dandan Bi > > --- > > BaseTools/Source/C/VfrCompile/VfrSyntax.g | 23 > > ++++++++++++++++++++--- > > 1 file changed, 20 insertions(+), 3 deletions(-) > > > > diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > index 4b0a43606ea..84dd2c3ed3f 100644 > > --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > @@ -4084,11 +4084,19 @@ vfrStatementInvalidSaveRestoreDefaults : > > > > // > > // Root expression extension function called by other function. > > // > > vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount =3D 0] : > > - << if ($RootLevel =3D=3D 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex= >=3D > > MAX_IFR_EXPRESSION_DEPTH) _PCATCH > (VFR_RETURN_INVALID_PARAMETER, 0, > > "The depth of expression exceeds the max supported level 8!"); > > _CLEAR_SAVED_OPHDR ();} >> > > + << > > + if ($RootLev= el =3D=3D 0) { > > + mCIfrOpHdr= Index ++; > > + if (mCIfrO= pHdrIndex >=3D > MAX_IFR_EXPRESSION_DEPTH) { > > + _PCATCH > (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds > the max supported level 8!"); > > + } > > + _INIT_OPHD= R_COND (); > > + } > > + >> > > andTerm[$RootLevel, $ExpOpCount] > > ( > > L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount+= +; > CIfrOr OObj(L->getLine()); >> > > )* > > << @@ -4988,10 > > +4996,11 @@ private: > > CIfrOpHeader * mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH]; > > UINT32 mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH]; > > UINT8 mCIfrOpHdrIndex; > > VOID _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, > UINT32 LineNo =3D 0); > > VOID _CLEAR_SAVED_OPHDR (VOID); > > + VOID _INIT_OPHDR_COND (VOID); > > BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID); > > > > > > EFI_VARSTORE_INFO mCurrQestVarInfo; > > EFI_GUID *mOverrideClassGuid; > > @@ -5077,20 +5086,28 @@ EfiVfrParser::_SAVE_OPHDR_COND ( > > mCIfrOpHdr[mCIfrOpHdrIndex] =3D new CIfrOpHeader(OpHdr); > > mCIfrOpHdrLineNo[mCIfrOpHdrIndex] =3D LineNo; > > } > > } > > > > +VOID > > +EfiVfrParser::_INIT_OPHDR_COND ( > > + VOID > > + ) > > +{ > > + mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; > > + mCIfrOpHdrLineNo[mCIfrOpHdrIndex] =3D 0; } > > + > > VOID > > 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; } > > > > BOOLEAN > > EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( > > VOID > > -- > > 2.14.3.windows.1 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel