[sr-dev] git:master: registrar: reset r-uri pointer after backup in lookup_branches( )

Daniel-Constantin Mierla miconda at gmail.com
Wed Sep 4 23:00:21 CEST 2013


Module: sip-router
Branch: master
Commit: 9b44e4b48862947f2ea634c6dd611ce7c07546a2
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9b44e4b48862947f2ea634c6dd611ce7c07546a2

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Sep  4 22:59:13 2013 +0200

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

- otherwise can be invalidated by next branch lookup

---

 modules/registrar/lookup.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/modules/registrar/lookup.c b/modules/registrar/lookup.c
index be08056..0e298e7 100644
--- a/modules/registrar/lookup.c
+++ b/modules/registrar/lookup.c
@@ -421,6 +421,11 @@ int lookup_branches(sip_msg_t *msg, udomain_t *d)
 	ruri_b_ruid = msg->ruid;
 	ruri_b_ua = msg->location_ua;
 	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);
@@ -490,7 +495,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;




More information about the sr-dev mailing list