From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Eric Dong <eric.dong@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [patch 1/2] BaseTools/VfrCompile:Fix memory leak issues
Date: Tue, 10 Apr 2018 15:54:46 +0800 [thread overview]
Message-ID: <20180410075447.121560-1-dandan.bi@intel.com> (raw)
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
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
next reply other threads:[~2018-04-10 7:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-10 7:54 Dandan Bi [this message]
2018-04-10 7:54 ` [patch 2/2] BaseTool/VfrCompile: make delete[] match with new[] Dandan Bi
2018-04-17 8:17 ` Dong, Eric
2018-04-17 8:17 ` [patch 1/2] BaseTools/VfrCompile:Fix memory leak issues Dong, Eric
2018-05-08 9:45 ` Gary Lin
2018-05-08 11:50 ` Bi, Dandan
2018-05-09 1:48 ` Gary Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180410075447.121560-1-dandan.bi@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox