Module: sip-router Branch: 4.1 Commit: 98091fef61e360627a18572619dd026fa4fa1acb URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=98091fef...
Author: Hugh Waite hugh.waite@acision.com Committer: Hugh Waite hugh.waite@acision.com Date: Tue Dec 9 19:05:31 2014 +0000
registrar: Fix memory leak around path and outbound header parsing
- Fix leak of parsed URI and URI parameters during a call to save() (cherry picked from commit 56c880120c07443eceb732117f0f1aa3558dcfe5)
---
modules/registrar/path.c | 10 ++-------- modules/registrar/save.c | 6 +++++- 2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/modules/registrar/path.c b/modules/registrar/path.c index cefd59a..1ce7c31 100644 --- a/modules/registrar/path.c +++ b/modules/registrar/path.c @@ -96,6 +96,8 @@ int build_path_vector(struct sip_msg *_m, str *path, str *received) LM_ERR("failed to parse parameters of first hop\n"); goto error; } + /* Not interested in param body - just the hooks */ + free_params(params);
if (hooks.contact.received) { uri_str.s = uri_buf; @@ -107,14 +109,6 @@ int build_path_vector(struct sip_msg *_m, str *path, str *received) *received = uri_str; LM_DBG("received is <%.*s>\n", received->len, received->s); } - - /*for (;params; params = params->next) { - if (params->type == P_RECEIVED) { - *received = hooks.contact.received->body; - break; - } - }*/ - free_params(params); } free_rr(&route); } diff --git a/modules/registrar/save.c b/modules/registrar/save.c index 7882332..fd5471b 100644 --- a/modules/registrar/save.c +++ b/modules/registrar/save.c @@ -923,17 +923,21 @@ int save(struct sip_msg* _m, udomain_t* _d, int _cflags, str *_uri) } if (parse_uri(route->nameaddr.uri.s, route->nameaddr.uri.len, &puri) < 0) { LM_ERR("Failed to parse Path: URI\n"); + free_rr(&route); goto error; } if (parse_params(&puri.params, CLASS_URI, &hooks, ¶ms) != 0) { LM_ERR("Failed to parse Path: URI parameters\n"); + free_rr(&route); goto error; } + /* Not interested in param body - just the hooks */ + free_params(params); if (!hooks.uri.ob) { /* No ;ob parameter to top Path: URI - no outbound */ use_ob = 0; } - + free_rr(&route); } else { /* No Path: header - no outbound */ use_ob = 0;