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

index 93cb6c3ac31427f1de6e6f4c4c3c32618f708f76..44dbccf9ad2bd046f9e50b4cf946b9dedc3b08b6 100644 (file)
@@ -1906,7 +1906,7 @@ Returns:
     FileBuffer = (UINT8 *) malloc (InputLength);\r
     if (FileBuffer == NULL) {\r
       Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!");\r
     FileBuffer = (UINT8 *) malloc (InputLength);\r
     if (FileBuffer == NULL) {\r
       Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!");\r
-      return 1;\r
+      goto ERROR;\r
     }\r
 \r
     Status = GetFileContents (\r
     }\r
 \r
     Status = GetFileContents (\r
@@ -1917,8 +1917,8 @@ Returns:
   }\r
 \r
   if (EFI_ERROR(Status)) {\r
   }\r
 \r
   if (EFI_ERROR(Status)) {\r
-    free(FileBuffer);\r
-    return 1;\r
+    Error (NULL, 0, 0004, "Error getting contents of file: %s", InputFileName);\r
+    goto ERROR;\r
   }\r
 \r
   if (OutputFileName == NULL) {\r
   }\r
 \r
   if (OutputFileName == NULL) {\r