BaseTools/TianoCompress: Fix potential memory leak

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>
diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 93cb6c3..44dbccf 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -1906,7 +1906,7 @@
     FileBuffer = (UINT8 *) malloc (InputLength);

     if (FileBuffer == NULL) {

       Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!");

-      return 1;

+      goto ERROR;

     }

 

     Status = GetFileContents (

@@ -1917,8 +1917,8 @@
   }

 

   if (EFI_ERROR(Status)) {

-    free(FileBuffer);

-    return 1;

+    Error (NULL, 0, 0004, "Error getting contents of file: %s", InputFileName);

+    goto ERROR;

   }

 

   if (OutputFileName == NULL) {