pidgin: f04d31e9: Modified version of a patch from "dseven...

resiak at soc.pidgin.im resiak at soc.pidgin.im
Sat Apr 12 13:50:48 EDT 2008


-----------------------------------------------------------------
Revision: f04d31e96f7a749f54961a71f7a4e0aa2fc0c7ac
Ancestor: 826ffa5b206886c18f53cd9271876ae6b4f0340c
Author: resiak at soc.pidgin.im
Date: 2008-04-12T17:48:16
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f04d31e96f7a749f54961a71f7a4e0aa2fc0c7ac

Modified files:
        pidgin/gtkconv.c

ChangeLog: 

Modified version of a patch from "dseven" to prevent crashing on NULL topics
with prehistoric Gtk.  Fixes #5205.  Thanks!

-------------- next part --------------
============================================================
--- pidgin/gtkconv.c	9965c96e3759111943b63e426e8a50070afd2ff0
+++ pidgin/gtkconv.c	ebcd8aef66b552c2dd3407ad88958f423b51b297
@@ -6538,7 +6538,9 @@ pidgin_conv_update_fields(PurpleConversa
 				markup = title;
 			}
 		} else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
-			const char *topic = gtkconv->u.chat->topic_text ? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text)) : NULL;
+			const char *topic = gtkconv->u.chat->topic_text
+				? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text))
+				: NULL;
 			char *esc = NULL, *tmp;
 #if GTK_CHECK_VERSION(2,6,0)
 			esc = topic ? g_markup_escape_text(topic, -1) : NULL;
@@ -6548,20 +6550,22 @@ pidgin_conv_update_fields(PurpleConversa
 			int len = 0;
 			char *c;
 
-			tmp = g_strdup(topic);
-			c = tmp;
-			while(*c && len < 72) {
-				c = g_utf8_next_char(c);
-				len++;
-			}
-			if (len == 72) {
-				*c = '\0';
-				c = g_strdup_printf("%s...", tmp);
+			if (topic != NULL) {
+				tmp = g_strdup(topic);
+				c = tmp;
+				while(*c && len < 72) {
+					c = g_utf8_next_char(c);
+					len++;
+				}
+				if (len == 72) {
+					*c = '\0';
+					c = g_strdup_printf("%s...", tmp);
+					g_free(tmp);
+					tmp = c;
+				}
+				esc = g_markup_escape_text(tmp, -1);
 				g_free(tmp);
-				tmp = c;
 			}
-			esc = tmp ? g_markup_escape_text(tmp, -1) : NULL;
-			g_free(tmp);
 #endif
 			tmp = g_markup_escape_text(purple_conversation_get_title(conv), -1);
 			markup = g_strdup_printf("%s%s<span color='%s' size='smaller'>%s</span>",


More information about the Commits mailing list