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

@@ -33,6 +33,8 @@ extern BOOLEAN VfrCompatibleMode;
#define EFI_BITS_PER_UINT32 (1 << EFI_BITS_SHIFT_PER_UINT32)
#define BUFFER_SAFE_FREE(Buf) do { if ((Buf) != NULL) { delete (Buf); } } while (0);
#define ARRAY_SAFE_FREE(Buf) do { if ((Buf) != NULL) { delete[] (Buf); } } while (0);
class CVfrBinaryOutput {
public:
@@ -139,7 +141,7 @@ struct SVfrPackStackNode {
~SVfrPackStackNode (VOID) {
if (mIdentifier != NULL) {
delete mIdentifier;
delete[] mIdentifier;
}
mNext = NULL;
}