[gimp] app: plug a memory leak



commit 61530c74a41b1a43fbdf8710102afa24ac1e726a
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Tue Sep 6 18:39:45 2016 +0200

    app: plug a memory leak
    
    AddressSanitizer output (paths manually shortened)
    
    Direct leak of 96 byte(s) in 1 object(s) allocated from:
        #0 0x7f543247d1d0 in realloc (/lib64/libasan.so.3+0xc71d0)
        #1 0x7f542d3ad02f in g_realloc glib/glib/gmem.c:159
        #2 0x57918d in gimp_color_history_set_property gimp/app/widgets/gimpcolorhistory.c:169
        #3 0x7f542d681ec0 in object_set_property glib/gobject/gobject.c:1423
        #4 0x7f542d681ec0 in g_object_new_internal glib/gobject/gobject.c:1817
        #5 0x7f542d6839ed in g_object_new_valist glib/gobject/gobject.c:2042
        #6 0x7f542d683c73 in g_object_new glib/gobject/gobject.c:1626

 app/widgets/gimpcolorhistory.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpcolorhistory.c b/app/widgets/gimpcolorhistory.c
index 5d11c58..13f9cc9 100644
--- a/app/widgets/gimpcolorhistory.c
+++ b/app/widgets/gimpcolorhistory.c
@@ -57,6 +57,7 @@ enum
 #define COLOR_AREA_SIZE      20
 
 static void   gimp_color_history_constructed   (GObject           *object);
+static void   gimp_color_history_finalize      (GObject           *object);
 static void   gimp_color_history_set_property  (GObject           *object,
                                                 guint              property_id,
                                                 const GValue      *value,
@@ -90,6 +91,7 @@ gimp_color_history_class_init (GimpColorHistoryClass *klass)
   object_class->constructed  = gimp_color_history_constructed;
   object_class->set_property = gimp_color_history_set_property;
   object_class->get_property = gimp_color_history_get_property;
+  object_class->finalize     = gimp_color_history_finalize;
 
   history_signals[COLOR_SELECTED] =
     g_signal_new ("color-selected",
@@ -141,6 +143,17 @@ gimp_color_history_constructed (GObject *object)
 }
 
 static void
+gimp_color_history_finalize (GObject *object)
+{
+  GimpColorHistory *history = GIMP_COLOR_HISTORY (object);
+
+  g_free (history->color_areas);
+  history->color_areas = NULL;
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
 gimp_color_history_set_property (GObject      *object,
                                  guint         property_id,
                                  const GValue *value,


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