From: Hao Wu Date: Tue, 11 Oct 2016 07:47:55 +0000 (+0800) Subject: BaseTools/GenFv: Fix file handles not being closed X-Git-Tag: edk2-stable201903~5309 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=320ba37a567c91b716d7fd8c33e28681e00ee84e;hp=9639f7d3783f2e624d6e11be19c49461d62cb5b5 BaseTools/GenFv: Fix file handles not being closed Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Liming Gao --- 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; }