From f7e98581021b2dd29824f1de03c523b9c1ec617a Mon Sep 17 00:00:00 2001 From: "Bi, Dandan" Date: Tue, 27 Feb 2018 13:53:46 +0800 Subject: [PATCH] BaseTool/VfrCompile: make delete[] match with new[] REF: https://bugzilla.tianocore.org/show_bug.cgi?id=764 Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- 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 ff2a837dfc..84c0e59b76 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp @@ -2,7 +2,7 @@ VfrCompiler main class and main function. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
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 @@ -284,7 +284,7 @@ CVfrCompiler::AppendIncludePath ( strcat (IncludePaths, " -I "); strcat (IncludePaths, PathStr); if (mOptions.IncludePaths != NULL) { - delete mOptions.IncludePaths; + delete[] mOptions.IncludePaths; } mOptions.IncludePaths = IncludePaths; } @@ -313,7 +313,7 @@ CVfrCompiler::AppendCPreprocessorOptions ( strcat (Opt, " "); strcat (Opt, Options); if (mOptions.CPreprocessorOptions != NULL) { - delete mOptions.CPreprocessorOptions; + delete[] mOptions.CPreprocessorOptions; } mOptions.CPreprocessorOptions = Opt; } @@ -531,12 +531,12 @@ CVfrCompiler::~CVfrCompiler ( } 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; } @@ -965,11 +965,11 @@ main ( } 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 2366fac5a7..14771a2044 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp @@ -77,7 +77,7 @@ CVfrErrorHandle::~CVfrErrorHandle ( SVfrFileScopeRecord *pNode = NULL; if (mInputFileName != NULL) { - delete mInputFileName; + delete[] mInputFileName; } while (mScopeRecordListHead != NULL) { diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp index 090ee13ef9..b40bcdf21f 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp @@ -144,7 +144,7 @@ CFormPkg::~CFormPkg () pBNode = mBufferNodeQueueHead; mBufferNodeQueueHead = mBufferNodeQueueHead->mNext; if (pBNode->mBufferStart != NULL) { - delete pBNode->mBufferStart; + delete[] pBNode->mBufferStart; delete pBNode; } } @@ -1152,7 +1152,7 @@ CIfrRecordInfoDB::IfrRecordOutput ( SIfrRecord *pNode; if (TBuffer.Buffer != NULL) { - delete TBuffer.Buffer; + delete[] TBuffer.Buffer; } TBuffer.Size = 0; @@ -2259,7 +2259,7 @@ CIfrObj::_EMIT_PENDING_OBJ ( // update bin buffer to package data buffer // if (mObjBinBuf != NULL) { - delete mObjBinBuf; + delete[] mObjBinBuf; mObjBinBuf = ObjBinBuf; } diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 4c7c6f28ff..d48072a8ad 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -969,7 +969,7 @@ vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize, break; } } - if (TFName != NULL) { delete TFName; TFName = NULL; } + if (TFName != NULL) { delete[] TFName; TFName = NULL; } >> )* ) @@ -1166,7 +1166,7 @@ vfrStatementVarStoreEfi : VSEObj.SetSize ((UINT16) Size); VSEObj.SetName (StoreName); if (IsUEFI23EfiVarstore == FALSE && StoreName != NULL) { - delete StoreName; + delete[] StoreName; } >> ";" @@ -1324,7 +1324,7 @@ vfrQuestionBaseInfo[EFI_VARSTORE_INFO & Info, EFI_QUESTION_ID & QId, EFI_QUESION >> << if (VarIdStr != NULL) { - delete VarIdStr; + delete[] VarIdStr; } _SAVE_CURRQEST_VARINFO (Info); >> @@ -1511,7 +1511,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFl } QuestVarIdStr = VarIdStr; - if (VarStr != NULL) {delete VarStr;} + if (VarStr != NULL) {delete[] VarStr;} >> ) ; @@ -4667,7 +4667,7 @@ 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++; } >> @@ -4841,7 +4841,7 @@ setExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : } CIfrSet TSObj(L->getLine()); TSObj.SetVarInfo (&Info); - delete VarIdStr; + delete[] VarIdStr; $ExpOpCount++; } >> @@ -5474,7 +5474,7 @@ EfiVfrParser::_STRCAT ( NewStr[0] = '\0'; if (*Dest != NULL) { strcpy (NewStr, *Dest); - delete *Dest; + delete[] *Dest; } strcat (NewStr, Src); diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index c536498d77..9bdc54462c 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -2,7 +2,7 @@ Vfr common library functions. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
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 @@ -360,7 +360,7 @@ CVfrBufferConfig::Write ( case 'i' : // set info if (mItemListPos->mId != NULL) { - delete mItemListPos->mId; + delete[] mItemListPos->mId; } mItemListPos->mId = NULL; if (Id != NULL) { @@ -1630,7 +1630,7 @@ SVfrVarStorageNode::~SVfrVarStorageNode ( } if (mVarStoreType == EFI_VFR_VARSTORE_NAME) { - delete mStorageInfo.mNameSpace.mNameTable; + delete[] mStorageInfo.mNameSpace.mNameTable; } } @@ -3489,7 +3489,7 @@ CVfrStringDB::CVfrStringDB () CVfrStringDB::~CVfrStringDB () { if (mStringFileName != NULL) { - delete mStringFileName; + delete[] mStringFileName; } mStringFileName = NULL; } -- 2.39.2