[goffice] Fixed a memory leak in GocPolyline code. [#663355]



commit 8f4e6d11742827e14919ed3cb33c97e6f08b85fc
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Nov 5 08:01:48 2011 +0100

    Fixed a memory leak in GocPolyline code. [#663355]

 ChangeLog                     |    5 +++++
 NEWS                          |    1 +
 goffice/canvas/goc-polyline.c |   12 ++++++++++++
 3 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8e33527..98e9bdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-05  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/canvas/goc-polyline.c (goc_polyline_finalize),
+	(goc_polyline_class_init): fix memory leak. [#663355]
+
 2011-11-04  Jean Brefort  <jean brefort normalesup org>
 
 	* goffice/gtk/go-image-sel.ui: make the icon selector larger.
diff --git a/NEWS b/NEWS
index 59d7309..103242f 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ Jean:
 	* Make GSettings the default configuration backend.
 	* Add support for SVG images.
 	* Add some optional support for EPS images. [#663078]
+	* Fixed a memory leak in GocPolyline code. [#663355]
 
 Morten:
 	* Recognize scientific formats with longer exponents.
diff --git a/goffice/canvas/goc-polyline.c b/goffice/canvas/goc-polyline.c
index 3ecbd3d..e8c58e4 100644
--- a/goffice/canvas/goc-polyline.c
+++ b/goffice/canvas/goc-polyline.c
@@ -38,6 +38,8 @@ enum {
 	POLYLINE_PROP_SPLINE
 };
 
+static GObjectClass *parent_class;
+
 static void
 goc_polyline_set_property (GObject *gobject, guint param_id,
 				    GValue const *value, GParamSpec *pspec)
@@ -216,13 +218,23 @@ goc_polyline_init_style (G_GNUC_UNUSED GocStyledItem *item, GOStyle *style)
 }
 
 static void
+goc_polyline_finalize (GObject *obj)
+{
+	GocPolyline *polyline = GOC_POLYLINE (obj);
+	g_free (polyline->points);
+	parent_class->finalize (obj);
+}
+
+static void
 goc_polyline_class_init (GocItemClass *item_klass)
 {
 	GObjectClass *obj_klass = (GObjectClass *) item_klass;
 	GocStyledItemClass *gsi_klass = (GocStyledItemClass *) item_klass;
+	parent_class = g_type_class_peek_parent (item_klass);
 
 	gsi_klass->init_style = goc_polyline_init_style;
 
+	obj_klass->finalize = goc_polyline_finalize;
 	obj_klass->get_property = goc_polyline_get_property;
 	obj_klass->set_property = goc_polyline_set_property;
         g_object_class_install_property (obj_klass, POLYLINE_PROP_POINTS,



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