BaseTools/VfrCompile: Avoid freeing memory with mismatched functions

Memory allocated by operator new[] should be freed using delete[] to avoid
possible memory leak.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Hao Wu
2016-09-27 13:40:58 +08:00
parent a6ac965bca
commit fd5425230e
5 changed files with 22 additions and 20 deletions

View File

@@ -56,13 +56,13 @@ SPendingAssign::~SPendingAssign (
)
{
if (mKey != NULL) {
delete mKey;
delete[] mKey;
}
mAddr = NULL;
mLen = 0;
mLineNo = 0;
if (mMsg != NULL) {
delete mMsg;
delete[] mMsg;
}
mNext = NULL;
}
@@ -898,7 +898,7 @@ CFormPkg::DeclarePendingQuestion (
strcpy (NewStr, SName);
strcat (NewStr, VarStr + strlen (FName));
ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize);
delete NewStr;
delete[] NewStr;
}
} else {
ReturnCode = VFR_RETURN_UNSUPPORTED;