BaseTool/VfrCompile: Fix potential memory leak issue
authorBi, Dandan <dandan.bi@intel.com>
Tue, 27 Feb 2018 05:53:47 +0000 (13:53 +0800)
committerLiming Gao <liming.gao@intel.com>
Fri, 23 Mar 2018 06:59:01 +0000 (14:59 +0800)
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp

index 9bdc544..5cab7bb 100644 (file)
@@ -3504,6 +3504,10 @@ CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName)
     return;\r
   }\r
 \r
     return;\r
   }\r
 \r
+  if (mStringFileName != NULL) {\r
+    delete[] mStringFileName;\r
+  }\r
+\r
   FileLen = strlen (StringFileName) + 1;\r
   mStringFileName = new CHAR8[FileLen];\r
   if (mStringFileName == NULL) {\r
   FileLen = strlen (StringFileName) + 1;\r
   mStringFileName = new CHAR8[FileLen];\r
   if (mStringFileName == NULL) {\r