]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/TianoCompress/TianoCompress.c
BaseTools/TianoCompress: Fix potential memory leak
[mirror_edk2.git] / BaseTools / Source / C / TianoCompress / TianoCompress.c
index b994d933eb4cf4359e45151a26d0580deacd72aa..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
-      return 1;\r
+      goto ERROR;\r
     }\r
 \r
     Status = GetFileContents (\r
@@ -1917,8 +1917,8 @@ Returns:
   }\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
@@ -2215,7 +2215,7 @@ Returns:
   for (Char = 0; Char < NumOfChar; Char++) {\r
 \r
     Len = BitLen[Char];\r
-    if (Len == 0) {\r
+    if (Len == 0 || Len >= 17) {\r
       continue;\r
     }\r
 \r
@@ -2346,6 +2346,8 @@ Returns:
   volatile UINT16  Index;\r
   UINT32  Mask;\r
 \r
+  assert (nn <= NPT);\r
+\r
   Number = (UINT16) GetBits (Sd, nbit);\r
 \r
   if (Number == 0) {\r