changeset 15023:dd4160b36f80

[gaim-migrate @ 17805] Don't allow invalid plugin callbacks to registered (and eventually crash). Fix an unlikely leak. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 22 Nov 2006 00:43:42 +0000
parents 2d3c7f76cea0
children 36cfa2e714b7
files libgaim/prefs.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/prefs.c	Tue Nov 21 21:05:44 2006 +0000
+++ b/libgaim/prefs.c	Wed Nov 22 00:43:42 2006 +0000
@@ -617,6 +617,7 @@
 remove_pref(struct gaim_pref *pref)
 {
 	char *name;
+	GSList *l;
 
 	if(!pref || pref == &prefs)
 		return;
@@ -643,7 +644,11 @@
 
 	free_pref_value(pref);
 
-	g_slist_free(pref->callbacks);
+	while((l = pref->callbacks) != NULL) {
+		pref->callbacks = pref->callbacks->next;
+		g_free(l->data);
+		g_slist_free_1(l);
+	}
 	g_free(pref->name);
 	g_free(pref);
 }
@@ -1008,6 +1013,9 @@
 	struct pref_cb *cb;
 	static guint cb_id = 0;
 
+	g_return_val_if_fail(name != NULL, 0);
+	g_return_val_if_fail(func != NULL, 0);
+
 	pref = find_pref(name);
 	if (pref == NULL)
 		return 0;