Properly check if the message is error/reply before calling the reply handler.
authorSenko Rasic <senko.rasic@collabora.co.uk>
Mon, 29 Oct 2007 18:34:00 +0100
changeset 294 bd0b7673bc4a
parent 293 b4336dfa5b91
child 295 2455123bb158
Properly check if the message is error/reply before calling the reply handler.
loudmouth/lm-connection.c
--- a/loudmouth/lm-connection.c	Mon Oct 29 18:00:20 2007 +0100
+++ b/loudmouth/lm-connection.c	Mon Oct 29 18:34:00 2007 +0100
@@ -255,20 +255,24 @@
 		goto out;
 	}
 	
-	id = lm_message_node_get_attribute (m->node, "id");
-	
-	if (id) {
-		handler = g_hash_table_lookup (connection->id_handlers, id);
-		if (handler) {
-			result = _lm_message_handler_handle_message (handler, 
-								     connection,
-								     m);
-			g_hash_table_remove (connection->id_handlers, id);
+	if ((lm_message_get_sub_type (m) == LM_MESSAGE_SUB_TYPE_ERROR) ||
+	    (lm_message_get_sub_type (m) == LM_MESSAGE_SUB_TYPE_RESULT)) {
+		id = lm_message_node_get_attribute (m->node, "id");
+
+		if (id) {
+			handler = g_hash_table_lookup (connection->id_handlers, id);
+			if (handler) {
+				result = _lm_message_handler_handle_message (handler,
+									     connection,
+									     m);
+				g_hash_table_remove (connection->id_handlers,
+						    id);
+			}
 		}
-	}
-	
-	if (result == LM_HANDLER_RESULT_REMOVE_MESSAGE) {
-		goto out;
+
+		if (result == LM_HANDLER_RESULT_REMOVE_MESSAGE) {
+			goto out;
+		}
 	}
 
 	for (l = connection->handlers[lm_message_get_type (m)];