changeset 22544:387024e316d1

Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 26 Mar 2008 00:18:15 +0000
parents d56ec4910b6d
children e59156cf8752
files pidgin/gtkutils.c
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkutils.c	Tue Mar 25 14:45:48 2008 +0000
+++ b/pidgin/gtkutils.c	Wed Mar 26 00:18:15 2008 +0000
@@ -2956,8 +2956,9 @@
 
 static void connection_signed_off_cb(PurpleConnection *gc)
 {
-	GSList *list;
-	for (list = minidialogs; list; list = list->next) {
+	GSList *list, *l_next;
+	for (list = minidialogs; list; list = l_next) {
+		l_next = list->next;
 		if (g_object_get_data(G_OBJECT(list->data), "gc") == gc) {
 				gtk_widget_destroy(GTK_WIDGET(list->data));
 		}
@@ -3023,14 +3024,19 @@
 
 	va_start(args, user_data);
 	while ((button_text = va_arg(args, char*))) {
+		struct _old_button_clicked_cb_data *data = NULL;
+		PidginMiniDialogCallback wrapper_cb = NULL;
 		PidginUtilMiniDialogCallback callback =
 			va_arg(args, PidginUtilMiniDialogCallback);
-		struct _old_button_clicked_cb_data *data =
-			g_new0(struct _old_button_clicked_cb_data, 1);
-		data->cb = callback;
-		data->data = user_data;
+
+		if (callback != NULL) {
+			data = g_new0(struct _old_button_clicked_cb_data, 1);
+			data->cb = callback;
+			data->data = user_data;
+			wrapper_cb = old_mini_dialog_button_clicked_cb;
+		}
 		pidgin_mini_dialog_add_button(mini_dialog, button_text,
-			old_mini_dialog_button_clicked_cb, data);
+			wrapper_cb, data);
 		cb_datas = g_list_append(cb_datas, data);
 	}
 	va_end(args);