From bff242eb1fa14e7fce4cfd1f6c438e493b206d54 Mon Sep 17 00:00:00 2001 From: Vlad Patrascu Date: Tue, 7 May 2019 19:05:24 +0300 Subject: [PATCH] Fix the CMD_PARAM_NO_EXPAND parameter flag The fixup of parameters flagged wih CMD_PARAM_NO_EXPAND would fail if the string contained a '$' character not followed by a valid variable. (cherry picked from commit 307e8c8ad6ce9bd263a122c9e0a8164cf59a131e) --- mod_fix.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mod_fix.c b/mod_fix.c index fa3da607f0c..63618fb5211 100644 --- a/mod_fix.c +++ b/mod_fix.c @@ -85,7 +85,7 @@ int fix_cmd(struct cmd_param *params, action_elem_t *elems) struct cmd_param *param; gparam_p gp = NULL; int ret; - pv_elem_t *pve; + pv_elem_t *pve = NULL; regex_t *re = NULL; void *h; @@ -152,7 +152,8 @@ int fix_cmd(struct cmd_param *params, action_elem_t *elems) } else if (param->flags & CMD_PARAM_STR) { if (elems[i].type == STR_ST) { - if (pv_parse_format(&elems[i].u.s, &pve) < 0) { + if (!(param->flags & CMD_PARAM_NO_EXPAND) && + pv_parse_format(&elems[i].u.s, &pve) < 0) { LM_ERR("Failed to parse formatted string in param " "[%d]\n",i); ret = E_UNSPEC; @@ -162,7 +163,8 @@ int fix_cmd(struct cmd_param *params, action_elem_t *elems) if ((param->flags & CMD_PARAM_NO_EXPAND) || (!pve->next && pve->spec.type == PVT_NONE)) { /* ignoring/no variables in the provided string */ - pv_elem_free_all(pve); + if (pve) + pv_elem_free_all(pve); gp->v.sval = elems[i].u.s; gp->pval = &gp->v.sval;