Module: kamailio
Branch: 4.3
Commit: a311e9cc9af08d29926db2307b0e8bfd87f3e1a4
URL:
https://github.com/kamailio/kamailio/commit/a311e9cc9af08d29926db2307b0e8bf…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2016-12-15T09:35:25+01:00
dialplan: fix avp values when using PV_IDX_ITR
manual backport from cc2c3de5e859861b59265cc5a0d41ae968a08149
(cherry picked from commit 30f53f1484144d2069f5d3724a65e160bbb6adb5)
---
Modified: modules/dialplan/dp_repl.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a311e9cc9af08d29926db2307b0e8bf…
Patch:
https://github.com/kamailio/kamailio/commit/a311e9cc9af08d29926db2307b0e8bf…
---
diff --git a/modules/dialplan/dp_repl.c b/modules/dialplan/dp_repl.c
index bfeda07..959c4bc 100644
--- a/modules/dialplan/dp_repl.c
+++ b/modules/dialplan/dp_repl.c
@@ -67,9 +67,10 @@ int dpl_dyn_printf_s(sip_msg_t *msg, const pv_elem_p elem,
pv_elem_p e = NULL;
pv_elem_p t = NULL;
str s = STR_NULL;
+ str v = STR_NULL;
int ret = -1;
- if(elem==NULL||avp_elem==NULL||elem_prev==NULL) return -1;
+ if(elem==NULL||avp_elem==NULL||elem_prev==NULL||vexpr==NULL) return -1;
if(str_append(&(avp_elem->text), val, &s)<0) return -1;
if(pv_parse_format(&s, &e)<0) {
@@ -86,10 +87,18 @@ int dpl_dyn_printf_s(sip_msg_t *msg, const pv_elem_p elem,
}
if(*elem_prev) (*elem_prev)->next = e;
e->next = avp_elem->next;
- if(pv_printf_s(msg, e, vexpr)<0){
+ if(pv_printf_s(msg, e, &v)<0){
LM_ERR("cannot get avp pcre dynamic expression value\n");
goto clean;
}
+ /* pv_printf_s uses pv_get_buffer() we do need to copy */
+ vexpr->len = v.len;
+ vexpr->s = pkg_malloc(sizeof(char)*(v.len+1));
+ if(vexpr->s==NULL) {
+ PKG_MEM_ERROR;
+ goto clean;
+ }
+ strcpy(vexpr->s, v.s);
ret = 0;
clean:
if(s.s) pkg_free(s.s);
@@ -282,7 +291,12 @@ dpl_dyn_pcre_p dpl_dynamic_pcre_list(sip_msg_t *msg, str *expr)
}
clean:
if(elem) pv_elem_free_all(elem);
- while(l) { t = l->next; pkg_free(l); l = t;}
+ while(l) {
+ t = l->next;
+ if(l->s.s) pkg_free(l->s.s);
+ pkg_free(l);
+ l = t;
+ }
return re_list;
}