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.120; helo=mga04.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 A19B7225FA049 for ; Tue, 10 Apr 2018 00:55:08 -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 fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2018 00:55:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,431,1517904000"; d="scan'208";a="42120272" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga003.jf.intel.com with ESMTP; 10 Apr 2018 00:55:06 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Liming Gao Date: Tue, 10 Apr 2018 15:54:46 +0800 Message-Id: <20180410075447.121560-1-dandan.bi@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [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, 10 Apr 2018 07:55:08 -0000 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 ExpOpCount = 0] : } } } if ($RootLevel == 0) { + _CLEAR_SAVED_OPHDR (); mCIfrOpHdrIndex --; } >> ; @@ -4387,10 +4388,16 @@ vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : ">" V5:Number << ConstVal = _STOU16(V5->getText(), V5->getLine()); >> << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >> ) ) + << + if (VarIdStr != NULL) { + delete[] VarIdStr; + VarIdStr = NULL; + } + >> ; ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : << EFI_QUESTION_ID QId; @@ -4440,10 +4447,16 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : ">" V5:Number << ConstVal = _STOU16(V5->getText(), V5->getLine()); >> << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >> ) ) + << + if (VarIdStr != NULL) { + delete[] VarIdStr; + VarIdStr = NULL; + } + >> ; 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] != NULL) { + delete[] VarIdStr[0]; + VarIdStr[0] = NULL; + } + if (VarIdStr[1] != NULL) { + delete[] VarIdStr[1]; + VarIdStr[1] = NULL; + } + >> ; ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << UINT16 ListLen = 0; @@ -4531,10 +4554,14 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : if (QId == EFI_QUESTION_ID_INVALID) { EILObj.SetQuestionId (QId, VarIdStr, LineNo); } $ExpOpCount++; } + if (VarIdStr != NULL) { + delete[] VarIdStr; + VarIdStr = NULL; + } >> ; questionref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << @@ -5055,11 +5082,14 @@ EfiVfrParser::_SAVE_OPHDR_COND ( VOID EfiVfrParser::_CLEAR_SAVED_OPHDR ( VOID ) { - mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; + if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) { + delete mCIfrOpHdr[mCIfrOpHdrIndex]; + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; + } mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; } BOOLEAN EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( -- 2.14.3.windows.1