Ver código fonte

presence: keep first dialog node reference to compare name with next nodes

- there can be intermediary nodes of other type making the match fail
- related to GH #1425

(cherry picked from commit 29d09b38fab5a1ee8d7f6f82818e3d3446d4dd8b)
Daniel-Constantin Mierla 7 anos atrás
pai
commit
190f1a4620
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      src/modules/presence/presentity.c

+ 3 - 2
src/modules/presence/presentity.c

@@ -312,6 +312,7 @@ int ps_match_dialog_state_from_body(str body, int *is_dialog, char *vstate)
 {
 	xmlDocPtr doc;
 	xmlNodePtr node;
+	xmlNodePtr fnode;
 	xmlNodePtr childNode;
 	char *tmp_state;
 	int rmatch = 0;
@@ -325,7 +326,7 @@ int ps_match_dialog_state_from_body(str body, int *is_dialog, char *vstate)
 		return -1;
 	}
 
-	node = xmlNodeGetChildByName(doc->children, "dialog");
+	fnode = node = xmlNodeGetChildByName(doc->children, "dialog");
 
 	while(node != NULL)
 	{
@@ -348,7 +349,7 @@ int ps_match_dialog_state_from_body(str body, int *is_dialog, char *vstate)
 		/* search for next dialog node */
 		do {
 			if(node->next != NULL && node->next->name != NULL
-					&& xmlStrcmp(node->name, node->next->name) == 0) {
+					&& xmlStrcmp(fnode->name, node->next->name) == 0) {
 				node = node->next;
 				break;
 			}