[evolution-patches] 43321 cal-backend crash



The code was assuming that priv->categories and priv->changed_categories
contained completely distinct objects, but that's only half true...
 
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1774
diff -u -r1.1774 ChangeLog
--- ChangeLog	19 May 2003 17:06:13 -0000	1.1774
+++ ChangeLog	19 May 2003 20:11:10 -0000
@@ -1,3 +1,9 @@
+2003-05-19  Dan Winship  <danw ximian com>
+
+	* pcs/cal-backend.c (cal_backend_finalize): Don't double-free
+	newly-added categories that the gui hasn't been told about yet.
+	#43321
+
 2003-05-19  Anna Marie Dirks  <anna ximian com>
 
 	* gui/e-meeting-time-sel.c:  (e_meeting_time_selector_construct): 
Index: pcs/cal-backend.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/pcs/cal-backend.c,v
retrieving revision 1.93
diff -u -r1.93 cal-backend.c
--- pcs/cal-backend.c	26 Apr 2003 16:44:48 -0000	1.93
+++ pcs/cal-backend.c	19 May 2003 20:11:12 -0000
@@ -222,6 +222,16 @@
 	g_free (c);
 }
 
+static gboolean
+prune_changed_categories (gpointer key, gpointer value, gpointer data)
+{
+	CalBackendCategory *c = value;
+
+	if (!c->refcount)
+		free_category_cb (key, value, data);
+	return TRUE;
+}
+
 void
 cal_backend_finalize (GObject *object)
 {
@@ -232,12 +242,12 @@
 
 	g_assert (priv->clients == NULL);
 
+	g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL);
+	g_hash_table_destroy (priv->changed_categories);
+
 	g_hash_table_foreach (priv->categories, free_category_cb, NULL);
 	g_hash_table_destroy (priv->categories);
 
-	g_hash_table_foreach (priv->changed_categories, free_category_cb, NULL);
-	g_hash_table_destroy (priv->changed_categories);
-
 	if (priv->category_idle_id)
 		g_source_remove (priv->category_idle_id);
 
@@ -1150,18 +1160,6 @@
 		cal_notify_categories_changed (l->data, seq);
 
 	CORBA_free (seq);
-}
-
-static gboolean
-prune_changed_categories (gpointer key, gpointer value, gpointer data)
-{
-	CalBackendCategory *category = value;
-
-	if (!category->refcount) {
-		g_free (category->name);
-		g_free (category);
-	}
-	return TRUE;
 }
 
 static gboolean


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