Cc: Liming Gao <liming....@intel.com> Cc: Yonghong Zhu <yonghong....@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a...@intel.com> --- BaseTools/Source/C/TianoCompress/TianoCompress.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c b/BaseTools/Source/C/TianoCompress/TianoCompress.c index 44dbccf..f810511 100644 --- a/BaseTools/Source/C/TianoCompress/TianoCompress.c +++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c @@ -1764,6 +1764,8 @@ Returns: InputLength = 0; InputFileName = NULL; OutputFileName = NULL; + InputFile = NULL; + OutputFile = NULL; DstSize=0; DebugLevel = 0; DebugMode = FALSE; @@ -1927,9 +1929,6 @@ Returns: OutputFile = fopen (LongFilePath (OutputFileName), "wb"); if (OutputFile == NULL) { Error (NULL, 0, 0001, "Error opening output file for writing", OutputFileName); - if (InputFile != NULL) { - fclose (InputFile); - } goto ERROR; } @@ -1962,6 +1961,8 @@ Returns: } fwrite(OutBuffer,(size_t)DstSize, 1, OutputFile); + fclose(OutputFile); + fclose(InputFile); free(Scratch); free(FileBuffer); free(OutBuffer); @@ -1999,6 +2000,8 @@ Returns: } fwrite(OutBuffer, (size_t)(Scratch->mOrigSize), 1, OutputFile); + fclose(OutputFile); + fclose(InputFile); free(Scratch); free(FileBuffer); free(OutBuffer); @@ -2021,6 +2024,12 @@ ERROR: DebugMsg(UTILITY_NAME, 0, DebugLevel, "Decoding Error\n", NULL); } } + if (OutputFile != NULL) { + fclose(OutputFile); + } + if (InputFile != NULL) { + fclose (InputFile); + } if (Scratch != NULL) { free(Scratch); } -- 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel