public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch 1/2] BaseTools/VfrCompile:Fix memory leak issues
@ 2018-04-10  7:54 Dandan Bi
  2018-04-10  7:54 ` [patch 2/2] BaseTool/VfrCompile: make delete[] match with new[] Dandan Bi
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dandan Bi @ 2018-04-10  7:54 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-09  1:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-10  7:54 [patch 1/2] BaseTools/VfrCompile:Fix memory leak issues Dandan Bi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox