summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/C/GenFv/GenFvInternalLib.c
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2016-10-11 15:47:55 +0800
committerHao Wu <hao.a.wu@intel.com>2016-11-08 16:38:02 +0800
commit320ba37a567c91b716d7fd8c33e28681e00ee84e (patch)
treef4bb7d977ec43d1870bb27a7cba197f87b96fdfa /BaseTools/Source/C/GenFv/GenFvInternalLib.c
parent9639f7d3783f2e624d6e11be19c49461d62cb5b5 (diff)
downloadedk2-320ba37a567c91b716d7fd8c33e28681e00ee84e.tar.gz
edk2-320ba37a567c91b716d7fd8c33e28681e00ee84e.tar.bz2
edk2-320ba37a567c91b716d7fd8c33e28681e00ee84e.zip
BaseTools/GenFv: 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/Source/C/GenFv/GenFvInternalLib.c')
-rw-r--r--BaseTools/Source/C/GenFv/GenFvInternalLib.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index bf6b40c4c4..8072c014fa 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -1161,6 +1161,7 @@ Returns:
//
FileBuffer = malloc (FileSize);
if (FileBuffer == NULL) {
+ fclose (NewFile);
Error (NULL, 0, 4001, "Resouce", "memory cannot be allocated!");
return EFI_OUT_OF_RESOURCES;
}
@@ -3506,6 +3507,7 @@ Returns:
PeFileSize = _filelength (fileno (PeFile));
PeFileBuffer = (UINT8 *) malloc (PeFileSize);
if (PeFileBuffer == NULL) {
+ fclose (PeFile);
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
return EFI_OUT_OF_RESOURCES;
}
@@ -3761,6 +3763,7 @@ Returns:
PeFileSize = _filelength (fileno (PeFile));
PeFileBuffer = (UINT8 *) malloc (PeFileSize);
if (PeFileBuffer == NULL) {
+ fclose (PeFile);
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
return EFI_OUT_OF_RESOURCES;
}