Module: kamailio Branch: master Commit: bd5873c4e33188238633a8f6c48a0c5c28041179 URL: https://github.com/kamailio/kamailio/commit/bd5873c4e33188238633a8f6c48a0c5c...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2017-07-21T08:56:10+02:00
dialplan: free allocated vars in case of errors
---
Modified: src/modules/dialplan/dialplan.c Modified: src/modules/dialplan/dp_repl.c
---
Diff: https://github.com/kamailio/kamailio/commit/bd5873c4e33188238633a8f6c48a0c5c... Patch: https://github.com/kamailio/kamailio/commit/bd5873c4e33188238633a8f6c48a0c5c...
---
diff --git a/src/modules/dialplan/dialplan.c b/src/modules/dialplan/dialplan.c index b319607e3d..e5710fd828 100644 --- a/src/modules/dialplan/dialplan.c +++ b/src/modules/dialplan/dialplan.c @@ -267,7 +267,7 @@ static int dp_update(struct sip_msg * msg, pv_spec_t * src, pv_spec_t * dest,
set_attr_pvar:
- if(!attr_pvar) + if(attr_pvar==NULL || attrs==NULL) return 0;
val.rs = *attrs; @@ -393,8 +393,10 @@ static int dp_trans_fixup(void ** param, int param_no){ }else{ lstr.s = p; lstr.len = strlen(p); dp_par->v.sp[0] = pv_cache_get(&lstr); - if (dp_par->v.sp[0]==NULL) + if (dp_par->v.sp[0]==NULL) { + pkg_free(dp_par); goto error; + }
verify_par_type(param_no, dp_par->v.sp[0]); dp_par->type = DP_VAL_SPEC; @@ -410,14 +412,18 @@ static int dp_trans_fixup(void ** param, int param_no){
lstr.s = p; lstr.len = strlen(p); dp_par->v.sp[0] = pv_cache_get(&lstr); - if(dp_par->v.sp[0]==NULL) + if(dp_par->v.sp[0]==NULL) { + pkg_free(dp_par); goto error; + }
if (s != 0) { lstr.s = s; lstr.len = strlen(s); dp_par->v.sp[1] = pv_cache_get(&lstr); - if (dp_par->v.sp[1]==NULL) + if (dp_par->v.sp[1]==NULL) { + pkg_free(dp_par); goto error; + } verify_par_type(param_no, dp_par->v.sp[1]); }
diff --git a/src/modules/dialplan/dp_repl.c b/src/modules/dialplan/dp_repl.c index 2c0d9b3b12..85741677df 100644 --- a/src/modules/dialplan/dp_repl.c +++ b/src/modules/dialplan/dp_repl.c @@ -234,7 +234,7 @@ dpl_dyn_pcre_p dpl_dynamic_pcre_list(sip_msg_t *msg, str *expr) l = pkg_malloc(sizeof(struct str_list)); if(l==NULL) { PKG_MEM_ERROR; - return NULL; + goto error; } memset(l, 0, sizeof(struct str_list)); if(dpl_get_avp_values(msg, elem, avp_elem, &l)<0) { @@ -342,8 +342,10 @@ struct subst_expr* repl_exp_parse(str subst) rw_no = 0;
repl = p; - if((rw_no = parse_repl(rw, &p, end, &max_pmatch, WITHOUT_SEP))< 0) + if((rw_no = parse_repl(rw, &p, end, &max_pmatch, WITHOUT_SEP))< 0) { + LM_ERR("parse repl failed\n"); goto error; + }
repl_end=p;
@@ -378,7 +380,6 @@ struct subst_expr* repl_exp_parse(str subst) error: if(shms.s != NULL) shm_free(shms.s); - if (se) { repl_expr_free(se);} return NULL; }