Przeglądaj źródła

registrar: reset r-uri pointer after backup in lookup_branches()

- otherwise can be invalidated by next branch lookup

(cherry picked from commit 9b44e4b48862947f2ea634c6dd611ce7c07546a2)
Daniel-Constantin Mierla 12 lat temu
rodzic
commit
9c8fd38683
1 zmienionych plików z 9 dodań i 0 usunięć
  1. 9 0
      modules/registrar/lookup.c

+ 9 - 0
modules/registrar/lookup.c

@@ -400,6 +400,11 @@ int lookup_branches(sip_msg_t *msg, udomain_t *d)
 	ruri_b_instance = msg->instance;
 	ruri_b_reg_id = msg->reg_id;
 	reset_ruri_branch(msg);
+	/* set new uri buf to null, otherwise is freed or overwritten by
+	 * rewrite_uri() during branch lookup */
+	msg->new_uri.len=0;
+	msg->new_uri.s=0;
+	msg->parsed_uri_ok=0;
 
 	for(i=0; i<nr_branches_start; i++) {
 		crt = get_sip_branch(i);
@@ -469,7 +474,11 @@ int lookup_branches(sip_msg_t *msg, udomain_t *d)
 
 done:
 	reset_ruri_branch(msg);
+	/* new uri could be set to allocated buffer by branch lookup */
+	if(msg->new_uri.s!=NULL)
+		pkg_free(msg->new_uri.s);
 	msg->new_uri = ruri_b_uri;
+	ruri_mark_new();
 	msg->parsed_uri_ok = 0;
 	msg->dst_uri = ruri_b_dst_uri;
 	msg->path_vec = ruri_b_path;