Module: kamailio Branch: 4.3 Commit: e827ccf957a341b7026b06f17686da7fcc426fc2 URL: https://github.com/kamailio/kamailio/commit/e827ccf957a341b7026b06f17686da7f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2015-10-11T03:39:58+02:00
textops: fix leak when subst_hf() with flag f is used
- substituion list was not freed
(cherry picked from commit 321a6140cdc7d6fd3f18f911af9825bb62575ace)
---
Modified: modules/textops/textops.c
---
Diff: https://github.com/kamailio/kamailio/commit/e827ccf957a341b7026b06f17686da7f... Patch: https://github.com/kamailio/kamailio/commit/e827ccf957a341b7026b06f17686da7f...
---
diff --git a/modules/textops/textops.c b/modules/textops/textops.c index 9aaada6..198332b 100644 --- a/modules/textops/textops.c +++ b/modules/textops/textops.c @@ -2844,6 +2844,7 @@ static int subst_hf_f(struct sip_msg *msg, char *str_hf, char *subst, char *flag begin=body.s;
off=begin-msg->buf; + if (lst) replace_lst_free(lst); lst=subst_run(se, begin, msg, &nmatches); body.s[body.len] = c; if(lst==0 && flags!=NULL && *flags=='f') @@ -2880,7 +2881,7 @@ static int subst_hf_f(struct sip_msg *msg, char *str_hf, char *subst, char *flag } /* if flags set for first header, then all done */ if(flags!=NULL && *flags=='f') - return ret; + goto done; } if(hfl!=NULL) { @@ -2892,6 +2893,7 @@ static int subst_hf_f(struct sip_msg *msg, char *str_hf, char *subst, char *flag begin=body.s;
off=begin-msg->buf; + if (lst) replace_lst_free(lst); lst=subst_run(se, begin, msg, &nmatches); body.s[body.len] = c; if(lst==0) @@ -2924,10 +2926,11 @@ static int subst_hf_f(struct sip_msg *msg, char *str_hf, char *subst, char *flag } } error: - LM_DBG("lst was %p\n", lst); - if (lst) replace_lst_free(lst); if (nmatches<0) LM_ERR("%s subst_run failed\n", exports.name); + LM_DBG("lst was %p\n", lst); +done: + if (lst) replace_lst_free(lst); return ret; }