[xchat-gnome] Fix another crasher.

Bill Nottingham notting at fedoraproject.org
Fri Jun 17 20:41:23 UTC 2011


commit 726af1c71293cf179dd3af62c88ef5bdc0aebf1d
Author: Bill Nottingham <notting at redhat.com>
Date:   Fri Jun 17 16:40:34 2011 -0400

    Fix another crasher.

 ...ist_remove-on-items-before-free-not-after.patch |   92 ++++++++++++++++++++
 xchat-gnome.spec                                   |    8 ++-
 2 files changed, 98 insertions(+), 2 deletions(-)
---
diff --git a/0004-Call-g_slist_remove-on-items-before-free-not-after.patch b/0004-Call-g_slist_remove-on-items-before-free-not-after.patch
new file mode 100644
index 0000000..2d0489f
--- /dev/null
+++ b/0004-Call-g_slist_remove-on-items-before-free-not-after.patch
@@ -0,0 +1,92 @@
+From 8dfd9e91bbf3de9084980ea19e4353ad88aa9399 Mon Sep 17 00:00:00 2001
+From: Bill Nottingham <notting at redhat.com>
+Date: Fri, 17 Jun 2011 16:38:23 -0400
+Subject: [PATCH 4/4] Call g_slist_remove on items before free(), not after.
+
+---
+ src/common/cfgfiles.c |    2 +-
+ src/common/plugin.c   |    2 +-
+ src/common/servlist.c |   22 +++++++++++-----------
+ 3 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
+index 6c70727..330967a 100644
+--- a/src/common/cfgfiles.c
++++ b/src/common/cfgfiles.c
+@@ -140,8 +140,8 @@ list_free (GSList ** list)
+ 	while (*list)
+ 	{
+ 		data = (void *) (*list)->data;
+-		free (data);
+ 		*list = g_slist_remove (*list, data);
++		free (data);
+ 	}
+ }
+ 
+diff --git a/src/common/plugin.c b/src/common/plugin.c
+index 0889dca..c6a67ac 100644
+--- a/src/common/plugin.c
++++ b/src/common/plugin.c
+@@ -160,9 +160,9 @@ xit:
+ 	}
+ 	if (pl->filename)
+ 		free ((char *)pl->filename);
+-	free (pl);
+ 
+ 	plugin_list = g_slist_remove (plugin_list, pl);
++	free (pl);
+ 
+ #ifdef USE_PLUGIN
+ 	fe_pluginlist_update ();
+diff --git a/src/common/servlist.c b/src/common/servlist.c
+index 3082966..b38ac4f 100644
+--- a/src/common/servlist.c
++++ b/src/common/servlist.c
+@@ -792,9 +792,9 @@ servlist_server_add (ircnet *net, char *name)
+ void
+ servlist_server_remove (ircnet *net, ircserver *serv)
+ {
++	net->servlist = g_slist_remove (net->servlist, serv);
+ 	free (serv->hostname);
+ 	free (serv);
+-	net->servlist = g_slist_remove (net->servlist, serv);
+ }
+ 
+ static void
+@@ -818,6 +818,16 @@ servlist_net_remove (ircnet *net)
+ 	servlist_server_remove_all (net);
+ 	network_list = g_slist_remove (network_list, net);
+ 
++	/* for safety */
++	list = serv_list;
++	while (list)
++	{
++		serv = list->data;
++		if (serv->network == net)
++			serv->network = NULL;
++		list = list->next;
++	}
++
+ 	if (net->nick)
+ 		free (net->nick);
+ 	if (net->nick2)
+@@ -840,16 +850,6 @@ servlist_net_remove (ircnet *net)
+ 		free (net->encoding);
+ 	free (net->name);
+ 	free (net);
+-
+-	/* for safety */
+-	list = serv_list;
+-	while (list)
+-	{
+-		serv = list->data;
+-		if (serv->network == net)
+-			serv->network = NULL;
+-		list = list->next;
+-	}
+ }
+ 
+ ircnet *
+-- 
+1.7.5.2
+
diff --git a/xchat-gnome.spec b/xchat-gnome.spec
index 23af58c..f4fe481 100644
--- a/xchat-gnome.spec
+++ b/xchat-gnome.spec
@@ -2,7 +2,7 @@
 
 Name:           xchat-gnome
 Version:        0.26.2
-Release:        1.git%{gitrev}%{?dist}
+Release:        2.git%{gitrev}%{?dist}
 Summary:        GNOME front-end to xchat
 
 Group:          Applications/Internet
@@ -28,6 +28,8 @@ Patch100:	0001-Dont-attempt-to-render-a-nonexistent-string.patch
 Patch101:	0002-Plugin_GetCurrent-can-return-NULL.patch
 # Don't crash on 32bpp depth
 Patch102:	0003-Ensure-pixmap-depth-matches-screen-window-depth.patch
+# free(foo); g_slist_remove(list, foo); is bad practice, mmmkay?
+Patch103:	0004-Call-g_slist_remove-on-items-before-free-not-after.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -77,6 +79,7 @@ common settings will be included in the main user interface. .
 %patch100 -p1 -b .empty
 %patch101 -p1 -b .nullplugin
 %patch102 -p1 -b .depth
+%patch103 -p1 -b .free
 
 %build
 ./autogen.sh
@@ -143,9 +146,10 @@ fi
 
 
 %changelog
-* Fri Jun 17 2011 Bill Nottingham <notting at redhat.com> - 0.26.2-1
+* Fri Jun 17 2011 Bill Nottingham <notting at redhat.com> - 0.26.2-2
 - fix crash on 32bpp depths with background images (#712626)
 - clean up some Gdk-CRITICAL messages
+- fix crash on exit in plugin code and elsewhere (#693122)
 
 * Thu Apr 07 2011 Bill Nottingham <notting at redhat.com> - 0.26.2-1
 - update to 0.26.2 (fixes #660840)


More information about the scm-commits mailing list