changeset 30627:7227c51730b0

jabber: Fix a crash when sending typing notifications to a malformed buddy E.g. "test@example.com ". Reported by Mark.
author Paul Aurich <paul@darkrain42.org>
date Thu, 17 Jun 2010 19:17:32 +0000
parents fcc36743697c
children d24c975c68a5 738741a7a692
files libpurple/protocols/jabber/message.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/message.c	Thu Jun 17 01:51:58 2010 +0000
+++ b/libpurple/protocols/jabber/message.c	Thu Jun 17 19:17:32 2010 +0000
@@ -1239,14 +1239,19 @@
 
 unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state)
 {
+	JabberStream *js;
 	JabberMessage *jm;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr;
-	char *resource = jabber_get_resource(who);
+	char *resource;	
 
-	jb = jabber_buddy_find(gc->proto_data, who, TRUE);
+	js = purple_connection_get_protocol_data(gc);
+	jb = jabber_buddy_find(js, who, TRUE);
+	if (!jb)
+		return 0;
+
+	resource = jabber_get_resource(who);
 	jbr = jabber_buddy_find_resource(jb, resource);
-
 	g_free(resource);
 
 	/* We know this entity doesn't support chat states */
@@ -1261,7 +1266,7 @@
 
 	/* TODO: figure out threading */
 	jm = g_new0(JabberMessage, 1);
-	jm->js = gc->proto_data;
+	jm->js = js;
 	jm->type = JABBER_MESSAGE_CHAT;
 	jm->to = g_strdup(who);
 	jm->id = jabber_get_next_id(jm->js);