]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/GenVtf: Fix potential memory leak
authorHao Wu <hao.a.wu@intel.com>
Tue, 11 Oct 2016 07:18:32 +0000 (15:18 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 8 Nov 2016 08:37:41 +0000 (16:37 +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/GenVtf/GenVtf.c

index 006822a79b08fd63ff0b55587a15edaf89910afc..a61502f3151e9ede3428ba49951fea1bfa2a891d 100644 (file)
@@ -1232,11 +1232,13 @@ Returns:
     Vtf1TotalSize += (UINT32) (FileSize + NumAdjustByte);\r
     Status = UpdateVtfBuffer (CompStartAddress, Buffer, FileSize, FIRST_VTF);\r
   } else {\r
+    free (Buffer);\r
     Error (NULL, 0, 2000,"Invalid Parameter", "There's component in second VTF so second BaseAddress and Size must be specified!");\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
+    free (Buffer);\r
     return EFI_ABORTED;\r
   }\r
 \r
@@ -1248,6 +1250,7 @@ Returns:
 \r
   CompFitPtr->CompAddress = CompStartAddress | IPF_CACHE_BIT;\r
   if ((FileSize % 16) != 0) {\r
+    free (Buffer);\r
     Error (NULL, 0, 2000, "Invalid parameter", "Binary FileSize must be a multiple of 16.");\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1389,6 +1392,7 @@ Returns:
   PalFitPtr->CompAddress  = PalStartAddress | IPF_CACHE_BIT;\r
   //assert ((FileSize % 16) == 0);\r
   if ((FileSize % 16) != 0) {\r
+    free (Buffer);\r
     Error (NULL, 0, 2000, "Invalid parameter", "Binary FileSize must be a multiple of 16.");\r
     return EFI_INVALID_PARAMETER;\r
   }\r