Module: sip-router
Branch: master
Commit: e1128c45dacf5b622c18f1cb8db0c45d8e6c9600
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e1128c4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Dec 29 16:22:28 2011 +0100
pua: check if totag len >0 before comparing it
- more on proper free of dlg_t structure
- patch by Laura Testi
---
modules_k/pua/hash.c | 1 +
modules_k/pua/pua.c | 47 ++++++++++++++++++++++-----------------
modules_k/pua/send_subscribe.c | 1 -
3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/modules_k/pua/hash.c b/modules_k/pua/hash.c
index 2ff15d5..ab8d145 100644
--- a/modules_k/pua/hash.c
+++ b/modules_k/pua/hash.c
@@ -373,6 +373,7 @@ ua_pres_t* get_dialog(ua_pres_t* dialog, unsigned int hash_code)
(p->watcher_uri->len== dialog->watcher_uri->len) &&
(strncmp(p->watcher_uri->s,dialog->watcher_uri->s,p->watcher_uri->len
)==0)&&
(strncmp(p->call_id.s, dialog->call_id.s, p->call_id.len)== 0) &&
+ p->to_tag.len > 0 &&
(strncmp(p->to_tag.s, dialog->to_tag.s, p->to_tag.len)== 0) &&
(strncmp(p->from_tag.s, dialog->from_tag.s, p->from_tag.len)== 0) )
{
diff --git a/modules_k/pua/pua.c b/modules_k/pua/pua.c
index 92c3d25..3b178ec 100644
--- a/modules_k/pua/pua.c
+++ b/modules_k/pua/pua.c
@@ -677,6 +677,8 @@ int update_pua(ua_pres_t* p)
int expires;
int result;
uac_req_t uac_r;
+ int ret_code = 0;
+ dlg_t* td = NULL;
if(p->desired_expires== 0)
expires= 3600;
@@ -693,7 +695,8 @@ int update_pua(ua_pres_t* p)
if(str_hdr == NULL)
{
LM_ERR("while building extra_headers\n");
- goto error;
+ ret_code = -1;
+ goto done;
}
LM_DBG("str_hdr:\n%.*s\n ", str_hdr->len, str_hdr->s);
@@ -701,7 +704,8 @@ int update_pua(ua_pres_t* p)
if(cb_param== NULL)
{
LM_ERR("while constructing publ callback param\n");
- goto error;
+ ret_code = -1;
+ goto done;
}
set_uac_req(&uac_r, &met, str_hdr, 0, 0, TMCB_LOCAL_COMPLETED,
@@ -717,36 +721,37 @@ int update_pua(ua_pres_t* p)
{
LM_ERR("in t_request function\n");
shm_free(cb_param);
- goto error;
+ ret_code = -1;
+ goto done;
}
-
}
else
{
str met= {"SUBSCRIBE", 9};
- dlg_t* td= NULL;
ua_pres_t* cb_param= NULL;
td= pua_build_dlg_t(p);
if(td== NULL)
{
LM_ERR("while building tm dlg_t structure");
- goto error;
+ ret_code = -1;
+ goto done;
};
str_hdr= subs_build_hdr(&p->contact, expires,p->event,p->extra_headers);
if(str_hdr== NULL || str_hdr->s== NULL)
{
- LM_ERR("while building extra headers\n");
- pkg_free(td);
- return -1;
+ if(p->event!=0)
+ LM_ERR("while building extra headers\n");
+ ret_code = -1;
+ goto done;
}
cb_param= subs_cbparam_indlg(p, expires, REQ_ME);
if(cb_param== NULL)
{
LM_ERR("while constructing subs callback param\n");
- goto error;
-
+ ret_code = -1;
+ goto done;
}
set_uac_req(&uac_r, &met, str_hdr, 0, td, TMCB_LOCAL_COMPLETED,
@@ -757,21 +762,21 @@ int update_pua(ua_pres_t* p)
{
LM_ERR("in t_request function\n");
shm_free(cb_param);
- pkg_free(td);
- goto error;
+ goto done;
}
-
+ }
+done:
+ if(td!=NULL)
+ {
+ if(td->route_set)
+ free_rr(&td->route_set);
pkg_free(td);
td= NULL;
- }
-
- pkg_free(str_hdr);
- return 0;
-
-error:
+ }
if(str_hdr)
pkg_free(str_hdr);
- return -1;
+
+ return ret_code;
}
diff --git a/modules_k/pua/send_subscribe.c b/modules_k/pua/send_subscribe.c
index a3b647c..3f73f86 100644
--- a/modules_k/pua/send_subscribe.c
+++ b/modules_k/pua/send_subscribe.c
@@ -1169,7 +1169,6 @@ insert:
if (dbmode!=PUA_DB_ONLY)
lock_release(&HashT->p_records[hash_code].lock);
ret= -1;
- pkg_free(td);
goto done;
}
if (dbmode!=PUA_DB_ONLY)