[gimp] CID 228155: Resource leak in file-tga.c



commit 0f8b9ed4aafdb55131cf15c8fbd2ed1ec55c8e64
Author: Sabri Ünal <libreajans gmail com>
Date:   Sat Oct 19 22:11:26 2019 +0000

    CID 228155: Resource leak in file-tga.c
    
    Variable fp going out of scope leaks the storage it points to.
    
    (cherry picked from commit e6b0b992df6530d4d199e4bb041d81e63d9122f3)

 plug-ins/common/file-tga.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/plug-ins/common/file-tga.c b/plug-ins/common/file-tga.c
index 39f7cfbbb0..53df61cac5 100644
--- a/plug-ins/common/file-tga.c
+++ b/plug-ins/common/file-tga.c
@@ -442,6 +442,7 @@ load_image (GFile   *file,
         {
           g_message (_("Cannot read footer from '%s'"),
                      gimp_file_get_utf8_name (file));
+          fclose (fp);
           return NULL;
         }
       else if (memcmp (footer + 8, magic, sizeof (magic)) == 0)
@@ -460,6 +461,7 @@ load_image (GFile   *file,
                 {
                   g_message (_("Cannot read extension from '%s'"),
                              gimp_file_get_utf8_name (file));
+                  fclose (fp);
                   return NULL;
                 }
               /* Eventually actually handle version 2 TGA here */
@@ -472,6 +474,7 @@ load_image (GFile   *file,
     {
       g_message (_("Cannot read header from '%s'"),
                  gimp_file_get_utf8_name (file));
+      fclose (fp);
       return NULL;
     }
 
@@ -547,6 +550,7 @@ load_image (GFile   *file,
             g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u)",
                        gimp_file_get_utf8_name (file),
                        info.imageType, info.bpp);
+            fclose (fp);
             return NULL;
           }
         break;
@@ -562,6 +566,7 @@ load_image (GFile   *file,
             g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u, alpha = %u)",
                        gimp_file_get_utf8_name (file),
                        info.imageType, info.bpp, info.alphaBits);
+            fclose (fp);
             return NULL;
           }
         break;
@@ -572,6 +577,7 @@ load_image (GFile   *file,
             g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u)",
                        gimp_file_get_utf8_name (file),
                        info.imageType, info.bpp);
+            fclose (fp);
             return NULL;
           }
         break;
@@ -579,6 +585,7 @@ load_image (GFile   *file,
       default:
         g_message ("Unknown image type %u for '%s'",
                    info.imageType, gimp_file_get_utf8_name (file));
+        fclose (fp);
         return NULL;
     }
 
@@ -588,6 +595,7 @@ load_image (GFile   *file,
       g_message ("Unhandled sub-format in '%s' (type = %u, bpp = %u)",
                  gimp_file_get_utf8_name (file),
                  info.imageType, info.bpp);
+      fclose (fp);
       return NULL;
     }
 
@@ -596,12 +604,14 @@ load_image (GFile   *file,
     {
       g_message ("Indexed image has invalid color map type %u",
                  info.colorMapType);
+      fclose (fp);
       return NULL;
     }
   else if (info.imageType != TGA_TYPE_MAPPED && info.colorMapType != 0)
     {
       g_message ("Non-indexed image has invalid color map type %u",
                  info.colorMapType);
+      fclose (fp);
       return NULL;
     }
 
@@ -610,6 +620,7 @@ load_image (GFile   *file,
     {
       g_message ("File '%s' is truncated or corrupted",
                  gimp_file_get_utf8_name (file));
+      fclose (fp);
       return NULL;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]