Module: sip-router
Branch: master
Commit: 41ee132aa1f2a900e281e2458b76fcaf781a79da
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=41ee132…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri May 1 13:55:06 2009 +0200
tm: free dst_uri.s in fake_req if failure
- free fake_req->dst_uri.s if no more pkg for fake_req->new_uri.s
---
modules/tm/t_reply.c | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 848cebb..8ab79c2 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -747,6 +747,19 @@ int fake_req(struct sip_msg *faked_req,
faked_req->parsed_uri_ok = 0;
faked_req->msg_flags|=extra_flags; /* set the extra tm flags */
+
+ /* dst_uri can change ALSO!!! -- make a private copy */
+ if (shmem_msg->dst_uri.s!=0 && shmem_msg->dst_uri.len!=0) {
+ faked_req->dst_uri.s=pkg_malloc(shmem_msg->dst_uri.len+1);
+ if (!faked_req->dst_uri.s) {
+ LOG(L_ERR, "ERROR: fake_req: no uri/pkg mem\n");
+ goto error01;
+ }
+ faked_req->dst_uri.len=shmem_msg->dst_uri.len;
+ memcpy( faked_req->dst_uri.s, shmem_msg->dst_uri.s,
+ faked_req->dst_uri.len);
+ faked_req->dst_uri.s[faked_req->dst_uri.len]=0;
+ }
/* new_uri can change -- make a private copy */
if (shmem_msg->new_uri.s!=0 && shmem_msg->new_uri.len!=0) {
faked_req->new_uri.s=pkg_malloc(shmem_msg->new_uri.len+1);
@@ -759,23 +772,16 @@ int fake_req(struct sip_msg *faked_req,
faked_req->new_uri.len);
faked_req->new_uri.s[faked_req->new_uri.len]=0;
}
- /* dst_uri can change ALSO!!! -- make a private copy */
- if (shmem_msg->dst_uri.s!=0 && shmem_msg->dst_uri.len!=0) {
- faked_req->dst_uri.s=pkg_malloc(shmem_msg->dst_uri.len+1);
- if (!faked_req->dst_uri.s) {
- LOG(L_ERR, "ERROR: fake_req: no uri/pkg mem\n");
- goto error00;
- }
- faked_req->dst_uri.len=shmem_msg->dst_uri.len;
- memcpy( faked_req->dst_uri.s, shmem_msg->dst_uri.s,
- faked_req->dst_uri.len);
- faked_req->dst_uri.s[faked_req->dst_uri.len]=0;
- }
if(uac) setbflagsval(0, uac->branch_flags);
else setbflagsval(0, 0);
return 1;
error00:
+ if (faked_req->dst_uri.s) {
+ pkg_free(faked_req->dst_uri.s);
+ faked_req->dst_uri.s = 0;
+ }
+error01:
return 0;
}