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=eric.dong@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 D5FF821F2E17B for ; Tue, 17 Apr 2018 01:17:12 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 01:17:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,462,1517904000"; d="scan'208";a="46782328" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 17 Apr 2018 01:17:12 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 17 Apr 2018 01:17:12 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 17 Apr 2018 01:17:11 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.40]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.109]) with mapi id 14.03.0319.002; Tue, 17 Apr 2018 16:17:07 +0800 From: "Dong, Eric" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [patch 1/2] BaseTools/VfrCompile:Fix memory leak issues Thread-Index: AQHT0KFE2g7LP6Wfz0mKFeE6xLl2aqQEp5rw Date: Tue, 17 Apr 2018 08:17:06 +0000 Message-ID: References: <20180410075447.121560-1-dandan.bi@intel.com> In-Reply-To: <20180410075447.121560-1-dandan.bi@intel.com> 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 1/2] BaseTools/VfrCompile:Fix memory leak issues 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, 17 Apr 2018 08:17:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: Bi, Dandan=20 Sent: Tuesday, April 10, 2018 3:55 PM To: edk2-devel@lists.01.org Cc: Dong, Eric ; Gao, Liming Subject: [patch 1/2] BaseTools/VfrCompile:Fix memory leak issues Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 32 +++++++++++++++++++++++++++= +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C= /VfrCompile/VfrSyntax.g index d48072a8adf..4b0a43606ea 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -4103,10 +4103,11 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 Ex= pOpCount =3D 0] : } } } =20 if ($RootLevel = =3D=3D 0) { + =20 + _CLEAR_SAVED_OPHDR (); mCIfrOpHdrInde= x --; } >> ; =20 @@ -4387,10 +4388,16 @@ vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCoun= t] : ">" V5:Number << ConstVal =3D _ST= OU16(V5->getText(), V5->getLine()); >> << IdEqValDoSpecial= ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); = >> ) ) + << + if (VarIdStr !=3D NULL) { + delete[] VarIdStr; + VarIdStr =3D NULL; + } + >> ; =20 ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : << EFI_QUESTION_ID QId; @@ -4440,10 +4447,16 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount= ] : ">" V5:Number << ConstVal =3D _ST= OU16(V5->getText(), V5->getLine()); >> << IdEqValDoSpecial= ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); = >> ) ) + << + if (VarIdStr !=3D NULL) { + delete[] VarIdStr; + VarIdStr =3D NULL; + } + >> ; =20 ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << EFI_QUESTION_ID QId[2]; @@ -4492,10 +4505,20 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] = : ">" vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]] << IdEqIdDoSpecial = ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[= 1], Mask[1], GREATER_THAN); >> ) ) + << + if (VarIdStr[0] !=3D NULL) { + delete[] VarIdStr[0]; + VarIdStr[0] =3D NULL; + } + if (VarIdStr[1] !=3D NULL) { + delete[] VarIdStr[1]; + VarIdStr[1] =3D NULL; + } + >> ; =20 ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << UINT16 ListLen =3D 0; @@ -4531,10 +4554,14 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCo= unt] : if (QId =3D=3D= EFI_QUESTION_ID_INVALID) { EILObj.SetQu= estionId (QId, VarIdStr, LineNo); } $ExpOpCount++; } + if (VarIdStr != =3D NULL) { + delete[] VarId= Str; + VarIdStr =3D N= ULL; + } >> ; =20 questionref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << @@ -5055,11 +5082,14 @@ EfiVfrParser::_SAVE_OPHDR_COND ( VOID EfiVfrParse= r::_CLEAR_SAVED_OPHDR ( VOID ) { - mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; + if (mCIfrOpHdr[mCIfrOpHdrIndex] !=3D NULL) { + delete mCIfrOpHdr[mCIfrOpHdrIndex]; + mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; + } mCIfrOpHdrLineNo[mCIfrOpHdrIndex] =3D 0; } =20 BOOLEAN EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( -- 2.14.3.windows.1