]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/GenFv: Fix file handles not being closed
authorHao Wu <hao.a.wu@intel.com>
Tue, 11 Oct 2016 07:47:55 +0000 (15:47 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 8 Nov 2016 08:38:02 +0000 (16:38 +0800)
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>
BaseTools/Source/C/GenFv/GenFvInternalLib.c

index bf6b40c4c47050bc3d101d8818257de2556364ed..8072c014faddc0d5e99641cf3322bc4f4bcecdbb 100644 (file)
@@ -1161,6 +1161,7 @@ Returns:
   //\r
   FileBuffer = malloc (FileSize);\r
   if (FileBuffer == NULL) {\r
+    fclose (NewFile);\r
     Error (NULL, 0, 4001, "Resouce", "memory cannot be allocated!");\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -3506,6 +3507,7 @@ Returns:
           PeFileSize = _filelength (fileno (PeFile));\r
           PeFileBuffer = (UINT8 *) malloc (PeFileSize);\r
           if (PeFileBuffer == NULL) {\r
+            fclose (PeFile);\r
             Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);\r
             return EFI_OUT_OF_RESOURCES;\r
           }\r
@@ -3761,6 +3763,7 @@ Returns:
         PeFileSize = _filelength (fileno (PeFile));\r
         PeFileBuffer = (UINT8 *) malloc (PeFileSize);\r
         if (PeFileBuffer == NULL) {\r
+          fclose (PeFile);\r
           Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);\r
           return EFI_OUT_OF_RESOURCES;\r
         }\r