public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[]
@ 2018-02-27  5:53 Dandan Bi
  2018-02-27  5:53 ` [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue Dandan Bi
  2018-03-23  6:56 ` [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[] Gao, Liming
  0 siblings, 2 replies; 4+ messages in thread
From: Dandan Bi @ 2018-02-27  5:53 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=764

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/VfrCompiler.cpp   | 14 +++++++-------
 BaseTools/Source/C/VfrCompile/VfrError.cpp      |  2 +-
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp    |  6 +++---
 BaseTools/Source/C/VfrCompile/VfrSyntax.g       | 14 +++++++-------
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp |  8 ++++----
 5 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
index ff2a837..84c0e59 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -1,10 +1,10 @@
 /** @file
   
   VfrCompiler main class and main function.
 
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution.  The full text of the license may be found at        
 http://opensource.org/licenses/bsd-license.php                                            
                                                                                           
@@ -282,11 +282,11 @@ CVfrCompiler::AppendIncludePath (
     strcat (IncludePaths, mOptions.IncludePaths);
   }
   strcat (IncludePaths, " -I ");
   strcat (IncludePaths, PathStr);
   if (mOptions.IncludePaths != NULL) {
-    delete mOptions.IncludePaths;
+    delete[] mOptions.IncludePaths;
   }
   mOptions.IncludePaths = IncludePaths;
 }
 
 VOID
@@ -311,11 +311,11 @@ CVfrCompiler::AppendCPreprocessorOptions (
     strcat (Opt, mOptions.CPreprocessorOptions);
   }
   strcat (Opt, " ");
   strcat (Opt, Options);
   if (mOptions.CPreprocessorOptions != NULL) {
-    delete mOptions.CPreprocessorOptions;
+    delete[] mOptions.CPreprocessorOptions;
   }
   mOptions.CPreprocessorOptions = Opt;
 }
 
 INT8
@@ -529,16 +529,16 @@ CVfrCompiler::~CVfrCompiler (
     free (mOptions.RecordListFile);
     mOptions.RecordListFile = NULL;
   }
 
   if (mOptions.IncludePaths != NULL) {
-    delete mOptions.IncludePaths;
+    delete[] mOptions.IncludePaths;
     mOptions.IncludePaths = NULL;
   }
 
   if (mOptions.CPreprocessorOptions != NULL) {
-    delete mOptions.CPreprocessorOptions;
+    delete[] mOptions.CPreprocessorOptions;
     mOptions.CPreprocessorOptions = NULL;
   }
 
   SET_RUN_STATUS(STATUS_DEAD);
 }
@@ -963,15 +963,15 @@ main (
   if ((Status == STATUS_DEAD) || (Status == STATUS_FAILED)) {
     return 2;
   }
 
   if (gCBuffer.Buffer != NULL) {
-    delete gCBuffer.Buffer;
+    delete[] gCBuffer.Buffer;
   }
   
   if (gRBuffer.Buffer != NULL) {
-    delete gRBuffer.Buffer;
+    delete[] gRBuffer.Buffer;
   }
 
   return GetUtilityStatus ();
 }
 
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp
index 2366fac..14771a2 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp
@@ -75,11 +75,11 @@ CVfrErrorHandle::~CVfrErrorHandle (
   )
 {
   SVfrFileScopeRecord *pNode = NULL;
 
   if (mInputFileName != NULL) {
-    delete mInputFileName;
+    delete[] mInputFileName;
   }
 
   while (mScopeRecordListHead != NULL) {
     pNode = mScopeRecordListHead;
     mScopeRecordListHead = mScopeRecordListHead->mNext;
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 090ee13..b40bcdf 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -142,11 +142,11 @@ CFormPkg::~CFormPkg ()
 
   while (mBufferNodeQueueHead != NULL) {
     pBNode = mBufferNodeQueueHead;
     mBufferNodeQueueHead = mBufferNodeQueueHead->mNext;
     if (pBNode->mBufferStart != NULL) {
-      delete pBNode->mBufferStart;
+      delete[] pBNode->mBufferStart;
       delete pBNode;
     }
   }
   mBufferNodeQueueTail = NULL;
   mCurrBufferNode      = NULL;
@@ -1150,11 +1150,11 @@ CIfrRecordInfoDB::IfrRecordOutput (
 {
   CHAR8      *Temp;
   SIfrRecord *pNode; 
 
   if (TBuffer.Buffer != NULL) {
-    delete TBuffer.Buffer;
+    delete[] TBuffer.Buffer;
   }
 
   TBuffer.Size = 0;
   TBuffer.Buffer = NULL;
 
@@ -2257,11 +2257,11 @@ CIfrObj::_EMIT_PENDING_OBJ (
   
   //
   // update bin buffer to package data buffer
   //
   if (mObjBinBuf != NULL) {
-    delete mObjBinBuf;
+    delete[] mObjBinBuf;
     mObjBinBuf = ObjBinBuf;
   }
   
   mDelayEmit = FALSE;
 }
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index 4c7c6f2..d48072a 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -967,11 +967,11 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize,
                  break;
               default:
                  break;
               }
             }
-            if (TFName != NULL) { delete TFName; TFName = NULL; }
+            if (TFName != NULL) { delete[] TFName; TFName = NULL; }
           >>
   )*
 )
 ;
 
@@ -1164,11 +1164,11 @@ vfrStatementVarStoreEfi :
                                                        VSEObj.SetVarStoreId (VarStoreId);
                                                        
                                                        VSEObj.SetSize ((UINT16) Size);
                                                        VSEObj.SetName (StoreName);
                                                        if (IsUEFI23EfiVarstore == FALSE && StoreName != NULL) {
-                                                         delete StoreName; 
+                                                         delete[] StoreName;
                                                        }
                                                     >>
   ";"
   ;
 
@@ -1322,11 +1322,11 @@ vfrQuestionBaseInfo[EFI_VARSTORE_INFO & Info, EFI_QUESTION_ID & QId, EFI_QUESION
                                                       _PCATCH(VFR_RETURN_FATAL_ERROR);
                                                       }
                                                    >>
                                                    <<
                                                       if (VarIdStr != NULL) {
-                                                        delete VarIdStr;
+                                                        delete[] VarIdStr;
                                                       }
                                                       _SAVE_CURRQEST_VARINFO (Info);
                                                    >>
   ;
 
@@ -1509,11 +1509,11 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl
                                                        case EFI_VFR_VARSTORE_NAME:
                                                        default: break;
                                                        }
 
                                                        QuestVarIdStr = VarIdStr;
-                                                       if (VarStr != NULL) {delete VarStr;}
+                                                       if (VarStr != NULL) {delete[] VarStr;}
                                                     >>
   )
   ;
 
 vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr, UINT32 &LineNo] :
@@ -4665,11 +4665,11 @@ getExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                               }
                                                             }
                                                             CIfrGet GObj(L->getLine()); 
                                                             _SAVE_OPHDR_COND (GObj, ($ExpOpCount == 0), L->getLine()); 
                                                             GObj.SetVarInfo (&Info); 
-                                                            delete VarIdStr; 
+                                                            delete[] VarIdStr;
                                                             $ExpOpCount++;
                                                           }
                                                        >>
   ;
 
@@ -4839,11 +4839,11 @@ setExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                                 _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support data array");
                                                               }
                                                             }
                                                             CIfrSet TSObj(L->getLine()); 
                                                             TSObj.SetVarInfo (&Info); 
-                                                            delete VarIdStr; 
+                                                            delete[] VarIdStr;
                                                             $ExpOpCount++;
                                                           }
                                                        >>
   ;
 
@@ -5472,11 +5472,11 @@ EfiVfrParser::_STRCAT (
     return;
   }
   NewStr[0] = '\0';
   if (*Dest != NULL) {
     strcpy (NewStr, *Dest);
-    delete *Dest;
+    delete[] *Dest;
   }
   strcat (NewStr, Src);
 
   *Dest = NewStr;
 }
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index c536498..9bdc544 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -1,10 +1,10 @@
 /** @file
   
   Vfr common library functions.
 
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution.  The full text of the license may be found at        
 http://opensource.org/licenses/bsd-license.php                                            
                                                                                           
@@ -358,11 +358,11 @@ CVfrBufferConfig::Write (
     mItemListPos = pItem->mNext;
     break;
 
   case 'i' : // set info
     if (mItemListPos->mId != NULL) {
-      delete mItemListPos->mId;
+      delete[] mItemListPos->mId;
     }
     mItemListPos->mId = NULL;
     if (Id != NULL) {
       if ((mItemListPos->mId = new CHAR8[strlen (Id) + 1]) == NULL) {
         return 2;
@@ -1628,11 +1628,11 @@ SVfrVarStorageNode::~SVfrVarStorageNode (
   if (mVarStoreName != NULL) {
     delete[] mVarStoreName;
   }
 
   if (mVarStoreType == EFI_VFR_VARSTORE_NAME) {
-    delete mStorageInfo.mNameSpace.mNameTable;
+    delete[] mStorageInfo.mNameSpace.mNameTable;
   }
 }
 
 CVfrDataStorage::CVfrDataStorage (
   VOID
@@ -3487,11 +3487,11 @@ CVfrStringDB::CVfrStringDB ()
 }
 
 CVfrStringDB::~CVfrStringDB ()
 {
   if (mStringFileName != NULL) {
-    delete mStringFileName;
+    delete[] mStringFileName;
   }
   mStringFileName = NULL;
 }
 
 
-- 
1.9.5.msysgit.1



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

* [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue
  2018-02-27  5:53 [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[] Dandan Bi
@ 2018-02-27  5:53 ` Dandan Bi
  2018-03-23  6:56   ` Gao, Liming
  2018-03-23  6:56 ` [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[] Gao, Liming
  1 sibling, 1 reply; 4+ messages in thread
From: Dandan Bi @ 2018-02-27  5:53 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=771

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/VfrUtilityLib.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 9bdc544..5cab7bb 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -3502,10 +3502,14 @@ CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName)
 
   if (StringFileName == NULL) {
     return;
   }
 
+  if (mStringFileName != NULL) {
+    delete[] mStringFileName;
+  }
+
   FileLen = strlen (StringFileName) + 1;
   mStringFileName = new CHAR8[FileLen];
   if (mStringFileName == NULL) {
     return;
   }
-- 
1.9.5.msysgit.1



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

* Re: [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[]
  2018-02-27  5:53 [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[] Dandan Bi
  2018-02-27  5:53 ` [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue Dandan Bi
@ 2018-03-23  6:56 ` Gao, Liming
  1 sibling, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-03-23  6:56 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Dong, Eric

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Bi, Dandan
> Sent: Tuesday, February 27, 2018 1:54 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[]
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=764
> 
> 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/VfrCompiler.cpp   | 14 +++++++-------
>  BaseTools/Source/C/VfrCompile/VfrError.cpp      |  2 +-
>  BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp    |  6 +++---
>  BaseTools/Source/C/VfrCompile/VfrSyntax.g       | 14 +++++++-------
>  BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp |  8 ++++----
>  5 files changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
> index ff2a837..84c0e59 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
> @@ -1,10 +1,10 @@
>  /** @file
> 
>    VfrCompiler main class and main function.
> 
> -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD License
>  which accompanies this distribution.  The full text of the license may be found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -282,11 +282,11 @@ CVfrCompiler::AppendIncludePath (
>      strcat (IncludePaths, mOptions.IncludePaths);
>    }
>    strcat (IncludePaths, " -I ");
>    strcat (IncludePaths, PathStr);
>    if (mOptions.IncludePaths != NULL) {
> -    delete mOptions.IncludePaths;
> +    delete[] mOptions.IncludePaths;
>    }
>    mOptions.IncludePaths = IncludePaths;
>  }
> 
>  VOID
> @@ -311,11 +311,11 @@ CVfrCompiler::AppendCPreprocessorOptions (
>      strcat (Opt, mOptions.CPreprocessorOptions);
>    }
>    strcat (Opt, " ");
>    strcat (Opt, Options);
>    if (mOptions.CPreprocessorOptions != NULL) {
> -    delete mOptions.CPreprocessorOptions;
> +    delete[] mOptions.CPreprocessorOptions;
>    }
>    mOptions.CPreprocessorOptions = Opt;
>  }
> 
>  INT8
> @@ -529,16 +529,16 @@ CVfrCompiler::~CVfrCompiler (
>      free (mOptions.RecordListFile);
>      mOptions.RecordListFile = NULL;
>    }
> 
>    if (mOptions.IncludePaths != NULL) {
> -    delete mOptions.IncludePaths;
> +    delete[] mOptions.IncludePaths;
>      mOptions.IncludePaths = NULL;
>    }
> 
>    if (mOptions.CPreprocessorOptions != NULL) {
> -    delete mOptions.CPreprocessorOptions;
> +    delete[] mOptions.CPreprocessorOptions;
>      mOptions.CPreprocessorOptions = NULL;
>    }
> 
>    SET_RUN_STATUS(STATUS_DEAD);
>  }
> @@ -963,15 +963,15 @@ main (
>    if ((Status == STATUS_DEAD) || (Status == STATUS_FAILED)) {
>      return 2;
>    }
> 
>    if (gCBuffer.Buffer != NULL) {
> -    delete gCBuffer.Buffer;
> +    delete[] gCBuffer.Buffer;
>    }
> 
>    if (gRBuffer.Buffer != NULL) {
> -    delete gRBuffer.Buffer;
> +    delete[] gRBuffer.Buffer;
>    }
> 
>    return GetUtilityStatus ();
>  }
> 
> diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp
> index 2366fac..14771a2 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp
> @@ -75,11 +75,11 @@ CVfrErrorHandle::~CVfrErrorHandle (
>    )
>  {
>    SVfrFileScopeRecord *pNode = NULL;
> 
>    if (mInputFileName != NULL) {
> -    delete mInputFileName;
> +    delete[] mInputFileName;
>    }
> 
>    while (mScopeRecordListHead != NULL) {
>      pNode = mScopeRecordListHead;
>      mScopeRecordListHead = mScopeRecordListHead->mNext;
> diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
> index 090ee13..b40bcdf 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
> @@ -142,11 +142,11 @@ CFormPkg::~CFormPkg ()
> 
>    while (mBufferNodeQueueHead != NULL) {
>      pBNode = mBufferNodeQueueHead;
>      mBufferNodeQueueHead = mBufferNodeQueueHead->mNext;
>      if (pBNode->mBufferStart != NULL) {
> -      delete pBNode->mBufferStart;
> +      delete[] pBNode->mBufferStart;
>        delete pBNode;
>      }
>    }
>    mBufferNodeQueueTail = NULL;
>    mCurrBufferNode      = NULL;
> @@ -1150,11 +1150,11 @@ CIfrRecordInfoDB::IfrRecordOutput (
>  {
>    CHAR8      *Temp;
>    SIfrRecord *pNode;
> 
>    if (TBuffer.Buffer != NULL) {
> -    delete TBuffer.Buffer;
> +    delete[] TBuffer.Buffer;
>    }
> 
>    TBuffer.Size = 0;
>    TBuffer.Buffer = NULL;
> 
> @@ -2257,11 +2257,11 @@ CIfrObj::_EMIT_PENDING_OBJ (
> 
>    //
>    // update bin buffer to package data buffer
>    //
>    if (mObjBinBuf != NULL) {
> -    delete mObjBinBuf;
> +    delete[] mObjBinBuf;
>      mObjBinBuf = ObjBinBuf;
>    }
> 
>    mDelayEmit = FALSE;
>  }
> diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> index 4c7c6f2..d48072a 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> @@ -967,11 +967,11 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize,
>                   break;
>                default:
>                   break;
>                }
>              }
> -            if (TFName != NULL) { delete TFName; TFName = NULL; }
> +            if (TFName != NULL) { delete[] TFName; TFName = NULL; }
>            >>
>    )*
>  )
>  ;
> 
> @@ -1164,11 +1164,11 @@ vfrStatementVarStoreEfi :
>                                                         VSEObj.SetVarStoreId (VarStoreId);
> 
>                                                         VSEObj.SetSize ((UINT16) Size);
>                                                         VSEObj.SetName (StoreName);
>                                                         if (IsUEFI23EfiVarstore == FALSE && StoreName != NULL) {
> -                                                         delete StoreName;
> +                                                         delete[] StoreName;
>                                                         }
>                                                      >>
>    ";"
>    ;
> 
> @@ -1322,11 +1322,11 @@ vfrQuestionBaseInfo[EFI_VARSTORE_INFO & Info, EFI_QUESTION_ID & QId, EFI_QUESION
>                                                        _PCATCH(VFR_RETURN_FATAL_ERROR);
>                                                        }
>                                                     >>
>                                                     <<
>                                                        if (VarIdStr != NULL) {
> -                                                        delete VarIdStr;
> +                                                        delete[] VarIdStr;
>                                                        }
>                                                        _SAVE_CURRQEST_VARINFO (Info);
>                                                     >>
>    ;
> 
> @@ -1509,11 +1509,11 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl
>                                                         case EFI_VFR_VARSTORE_NAME:
>                                                         default: break;
>                                                         }
> 
>                                                         QuestVarIdStr = VarIdStr;
> -                                                       if (VarStr != NULL) {delete VarStr;}
> +                                                       if (VarStr != NULL) {delete[] VarStr;}
>                                                      >>
>    )
>    ;
> 
>  vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr, UINT32 &LineNo] :
> @@ -4665,11 +4665,11 @@ getExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
>                                                                }
>                                                              }
>                                                              CIfrGet GObj(L->getLine());
>                                                              _SAVE_OPHDR_COND (GObj, ($ExpOpCount == 0),
> L->getLine());
>                                                              GObj.SetVarInfo (&Info);
> -                                                            delete VarIdStr;
> +                                                            delete[] VarIdStr;
>                                                              $ExpOpCount++;
>                                                            }
>                                                         >>
>    ;
> 
> @@ -4839,11 +4839,11 @@ setExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
>                                                                  _PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(),
> "Get/Set opcode don't support data array");
>                                                                }
>                                                              }
>                                                              CIfrSet TSObj(L->getLine());
>                                                              TSObj.SetVarInfo (&Info);
> -                                                            delete VarIdStr;
> +                                                            delete[] VarIdStr;
>                                                              $ExpOpCount++;
>                                                            }
>                                                         >>
>    ;
> 
> @@ -5472,11 +5472,11 @@ EfiVfrParser::_STRCAT (
>      return;
>    }
>    NewStr[0] = '\0';
>    if (*Dest != NULL) {
>      strcpy (NewStr, *Dest);
> -    delete *Dest;
> +    delete[] *Dest;
>    }
>    strcat (NewStr, Src);
> 
>    *Dest = NewStr;
>  }
> diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> index c536498..9bdc544 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> @@ -1,10 +1,10 @@
>  /** @file
> 
>    Vfr common library functions.
> 
> -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD License
>  which accompanies this distribution.  The full text of the license may be found at
>  http://opensource.org/licenses/bsd-license.php
> 
> @@ -358,11 +358,11 @@ CVfrBufferConfig::Write (
>      mItemListPos = pItem->mNext;
>      break;
> 
>    case 'i' : // set info
>      if (mItemListPos->mId != NULL) {
> -      delete mItemListPos->mId;
> +      delete[] mItemListPos->mId;
>      }
>      mItemListPos->mId = NULL;
>      if (Id != NULL) {
>        if ((mItemListPos->mId = new CHAR8[strlen (Id) + 1]) == NULL) {
>          return 2;
> @@ -1628,11 +1628,11 @@ SVfrVarStorageNode::~SVfrVarStorageNode (
>    if (mVarStoreName != NULL) {
>      delete[] mVarStoreName;
>    }
> 
>    if (mVarStoreType == EFI_VFR_VARSTORE_NAME) {
> -    delete mStorageInfo.mNameSpace.mNameTable;
> +    delete[] mStorageInfo.mNameSpace.mNameTable;
>    }
>  }
> 
>  CVfrDataStorage::CVfrDataStorage (
>    VOID
> @@ -3487,11 +3487,11 @@ CVfrStringDB::CVfrStringDB ()
>  }
> 
>  CVfrStringDB::~CVfrStringDB ()
>  {
>    if (mStringFileName != NULL) {
> -    delete mStringFileName;
> +    delete[] mStringFileName;
>    }
>    mStringFileName = NULL;
>  }
> 
> 
> --
> 1.9.5.msysgit.1



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

* Re: [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue
  2018-02-27  5:53 ` [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue Dandan Bi
@ 2018-03-23  6:56   ` Gao, Liming
  0 siblings, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-03-23  6:56 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Dong, Eric

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Bi, Dandan
> Sent: Tuesday, February 27, 2018 1:54 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=771
> 
> 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/VfrUtilityLib.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> index 9bdc544..5cab7bb 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
> @@ -3502,10 +3502,14 @@ CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName)
> 
>    if (StringFileName == NULL) {
>      return;
>    }
> 
> +  if (mStringFileName != NULL) {
> +    delete[] mStringFileName;
> +  }
> +
>    FileLen = strlen (StringFileName) + 1;
>    mStringFileName = new CHAR8[FileLen];
>    if (mStringFileName == NULL) {
>      return;
>    }
> --
> 1.9.5.msysgit.1



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

end of thread, other threads:[~2018-03-23  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-27  5:53 [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[] Dandan Bi
2018-02-27  5:53 ` [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue Dandan Bi
2018-03-23  6:56   ` Gao, Liming
2018-03-23  6:56 ` [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[] Gao, Liming

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