summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2016-10-11 15:56:40 +0800
committerHao Wu <hao.a.wu@intel.com>2016-11-08 16:38:10 +0800
commit4d32be8888f4b7d8e337259fe1a5afd71b6b0046 (patch)
tree7fe1f9ccc91b9695d1bcfb3e489797b8645cf1d6 /BaseTools
parent1880d5e4d0b12695bec02e72e154a415e5085298 (diff)
downloadedk2-4d32be8888f4b7d8e337259fe1a5afd71b6b0046.zip
edk2-4d32be8888f4b7d8e337259fe1a5afd71b6b0046.tar.gz
edk2-4d32be8888f4b7d8e337259fe1a5afd71b6b0046.tar.bz2
BaseTools/TianoCompress: Fix file handles not being closed
Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@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>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/TianoCompress/TianoCompress.c15
1 files 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);
}