[gimp] Bug 623169 - Memory leaks in GIMP



commit 4fea27ec1d1743a588bb2f06ec6240f17d95b748
Author: Nelson A. de Oliveira <naoliv debian org>
Date:   Tue Jun 22 16:10:28 2010 -0300

    Bug 623169 - Memory leaks in GIMP
    
    Add some missing g_free() and free() calls, found by cppcheck.

 plug-ins/common/file-gbr.c        |    2 ++
 plug-ins/common/file-pat.c        |    2 ++
 plug-ins/common/mosaic.c          |    6 +++++-
 plug-ins/common/plugin-browser.c  |    5 +++++
 plug-ins/file-ico/ico-save.c      |    1 +
 plug-ins/file-jpeg/jpeg-save.c    |    2 ++
 plug-ins/file-xjt/xjt.c           |    1 +
 plug-ins/flame/rect.c             |    1 +
 plug-ins/gfig/gfig-star.c         |    4 ++++
 plug-ins/gimpressionist/ppmtool.c |    2 ++
 10 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/common/file-gbr.c b/plug-ins/common/file-gbr.c
index 673722e..fa6af9c 100644
--- a/plug-ins/common/file-gbr.c
+++ b/plug-ins/common/file-gbr.c
@@ -265,6 +265,8 @@ run (const gchar      *name,
 
           strncpy (info.description, name, sizeof (info.description));
           info.description[sizeof (info.description) - 1] = '\0';
+
+          g_free (name);
         }
 
       switch (run_mode)
diff --git a/plug-ins/common/file-pat.c b/plug-ins/common/file-pat.c
index 617aeaf..0840440 100644
--- a/plug-ins/common/file-pat.c
+++ b/plug-ins/common/file-pat.c
@@ -235,6 +235,8 @@ run (const gchar      *name,
 
           strncpy (description, name, sizeof (description));
           description[sizeof (description) - 1] = '\0';
+
+          g_free (name);
         }
 
       switch (run_mode)
diff --git a/plug-ins/common/mosaic.c b/plug-ins/common/mosaic.c
index 88348cf..d900415 100644
--- a/plug-ins/common/mosaic.c
+++ b/plug-ins/common/mosaic.c
@@ -2122,7 +2122,11 @@ find_poly_dir (Polygon *poly,
     }
 
   if (!total)
-    return;
+    {
+      g_free (max_scanlines);
+      g_free (min_scanlines);
+      return;
+    }
 
   if ((gdouble) count / (gdouble) total > COUNT_THRESHOLD)
     {
diff --git a/plug-ins/common/plugin-browser.c b/plug-ins/common/plugin-browser.c
index 3cac344..4fa12f7 100644
--- a/plug-ins/common/plugin-browser.c
+++ b/plug-ins/common/plugin-browser.c
@@ -326,7 +326,10 @@ insert_into_tree_view (PluginBrowser *browser,
   str_ptr = strrchr (tmp_ptr, '/');
 
   if (str_ptr == NULL)
+  {
+    g_free (tmp_ptr);
     return; /* No node */
+  }
 
   leaf_ptr = g_strdup (str_ptr + 1);
 
@@ -352,6 +355,8 @@ insert_into_tree_view (PluginBrowser *browser,
                       TREE_COLUMN_DATE_STRING, xtimestr,
                       TREE_COLUMN_PINFO,       pinfo,
                       -1);
+
+  g_free (leaf_ptr);
 }
 
 static void
diff --git a/plug-ins/file-ico/ico-save.c b/plug-ins/file-ico/ico-save.c
index 011b8b8..464c245 100644
--- a/plug-ins/file-ico/ico-save.c
+++ b/plug-ins/file-ico/ico-save.c
@@ -1089,6 +1089,7 @@ ico_save_image (const gchar  *filename,
 
   ico_save_info_free (&info);
   fclose (fp);
+  g_free (entries);
 
   return GIMP_PDB_SUCCESS;
 }
diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c
index a25018c..645bde5 100644
--- a/plug-ins/file-jpeg/jpeg-save.c
+++ b/plug-ins/file-jpeg/jpeg-save.c
@@ -1289,6 +1289,8 @@ load_save_defaults (void)
 
   if (num_fields == 12)
     memcpy (&jsvals, &tmpvals, sizeof (tmpvals));
+
+  g_free (def_str);
 }
 
 static void
diff --git a/plug-ins/file-xjt/xjt.c b/plug-ins/file-xjt/xjt.c
index deaba7c..57f0c0f 100644
--- a/plug-ins/file-xjt/xjt.c
+++ b/plug-ins/file-xjt/xjt.c
@@ -3135,6 +3135,7 @@ p_load_linefile (const gchar *filename,
   l_fp = g_fopen(filename, "rb");
   if(l_fp == NULL)
   {
+    g_free(l_file_buff);
     return(NULL);
   }
   fread(l_file_buff, *len, 1, l_fp);
diff --git a/plug-ins/flame/rect.c b/plug-ins/flame/rect.c
index 9115f28..61c1acc 100644
--- a/plug-ins/flame/rect.c
+++ b/plug-ins/flame/rect.c
@@ -392,4 +392,5 @@ render_rectangle (frame_spec    *spec,
     }
 
   free (filter);
+  free (temporal_filter);
 }
diff --git a/plug-ins/gfig/gfig-star.c b/plug-ins/gfig/gfig-star.c
index 9de962b..5922b85 100644
--- a/plug-ins/gfig/gfig-star.c
+++ b/plug-ins/gfig/gfig-star.c
@@ -209,6 +209,8 @@ d_paint_star (GfigObject *obj)
 #ifdef DEBUG
       g_warning ("Internal error in star - no outer vertice point \n");
 #endif /* DEBUG */
+      g_free (line_pnts);
+      g_free (min_max);
       return;
     }
 
@@ -219,6 +221,8 @@ d_paint_star (GfigObject *obj)
 #ifdef DEBUG
       g_warning ("Internal error in star - no inner vertice point \n");
 #endif /* DEBUG */
+      g_free (line_pnts);
+      g_free (min_max);
       return;
     }
 
diff --git a/plug-ins/gimpressionist/ppmtool.c b/plug-ins/gimpressionist/ppmtool.c
index 01e63e1..c8d1bd8 100644
--- a/plug-ins/gimpressionist/ppmtool.c
+++ b/plug-ins/gimpressionist/ppmtool.c
@@ -357,6 +357,8 @@ ppm_load (const char *fn, ppm_t *p)
     fread (tmpcol, p->height * p->width, 1, f);
     for (y = 0; y < p->width * p->height * 3; y++) {
       p->col[y] = tmpcol[y / 3];
+
+    g_free (tmpcol);
     }
   }
   fclose (f);



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