changeset 18711:259f8635eeff

Fix a bunch of possible crashes in jabber when using slash commands in a room that you've been kicked out of
author Mark Doliner <mark@kingant.net>
date Sun, 29 Jul 2007 06:10:24 +0000
parents bdb9c5c8673f
children c65c4caa817a
files libpurple/protocols/jabber/jabber.c
diffstat 1 files changed, 25 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sat Jul 28 20:52:06 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sun Jul 29 06:10:24 2007 +0000
@@ -1618,6 +1618,10 @@
 		const char *cmd, char **args, char **error, void *data)
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
+
+	if (!chat)
+		return PURPLE_CMD_RET_FAILED;
+
 	jabber_chat_request_room_configure(chat);
 	return PURPLE_CMD_RET_OK;
 }
@@ -1626,6 +1630,10 @@
 		const char *cmd, char **args, char **error, void *data)
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
+
+	if (!chat)
+		return PURPLE_CMD_RET_FAILED;
+
 	jabber_chat_register(chat);
 	return PURPLE_CMD_RET_OK;
 }
@@ -1634,6 +1642,10 @@
 		const char *cmd, char **args, char **error, void *data)
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
+
+	if (!chat)
+		return PURPLE_CMD_RET_FAILED;
+
 	jabber_chat_change_topic(chat, args ? args[0] : NULL);
 	return PURPLE_CMD_RET_OK;
 }
@@ -1643,7 +1655,7 @@
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
 
-	if(!args || !args[0])
+	if(!chat || !args || !args[0])
 		return PURPLE_CMD_RET_FAILED;
 
 	jabber_chat_change_nick(chat, args[0]);
@@ -1654,6 +1666,10 @@
 		const char *cmd, char **args, char **error, void *data)
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
+
+	if (!chat)
+		return PURPLE_CMD_RET_FAILED;
+
 	jabber_chat_part(chat, args ? args[0] : NULL);
 	return PURPLE_CMD_RET_OK;
 }
@@ -1663,7 +1679,7 @@
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
 
-	if(!args || !args[0])
+	if(!chat || !args || !args[0])
 		return PURPLE_CMD_RET_FAILED;
 
 	if(!jabber_chat_ban_user(chat, args[0], args[1])) {
@@ -1679,7 +1695,7 @@
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
 
-	if (!args || !args[0] || !args[1])
+	if (!chat || !args || !args[0] || !args[1])
 		return PURPLE_CMD_RET_FAILED;
 
 	if (strcmp(args[1], "owner") != 0 && 
@@ -1704,7 +1720,7 @@
 {
 	JabberChat *chat;
 
-	if (!args || !args[0] || !args[1])
+	if (!chat || !args || !args[0] || !args[1])
 		return PURPLE_CMD_RET_FAILED;
 
 	if (strcmp(args[1], "moderator") != 0 &&
@@ -1745,7 +1761,7 @@
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
 	GHashTable *components;
 
-	if(!args || !args[0])
+	if(!chat || !args || !args[0])
 		return PURPLE_CMD_RET_FAILED;
 
 	components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
@@ -1767,7 +1783,7 @@
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
 
-	if(!args || !args[0])
+	if(!chat || !args || !args[0])
 		return PURPLE_CMD_RET_FAILED;
 
 	if(!jabber_chat_kick_user(chat, args[0], args[1])) {
@@ -1784,6 +1800,9 @@
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
 	char *who;
 
+	if (!chat)
+		return PURPLE_CMD_RET_FAILED;
+
 	who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
 
 	jabber_message_send_im(purple_conversation_get_gc(conv), who, args[1], 0);