dialplan: don't try to translate on dp_match()
authorVictor Seva <linuxmaniac@torreviejawireless.org>
Wed, 15 May 2019 08:00:56 +0000 (10:00 +0200)
committerVictor Seva <linuxmaniac@torreviejawireless.org>
Wed, 15 May 2019 09:37:41 +0000 (11:37 +0200)
fix #1952

src/modules/dialplan/dialplan.c
src/modules/dialplan/dp_repl.c

index 20b7744..7770679 100644 (file)
@@ -481,8 +481,9 @@ static int dp_replace_helper(sip_msg_t *msg, int dpid, str *input,
                pv_spec_t *pvd)
 {
        dpl_id_p idp;
-       str output = STR_NULL;
+       str tmp = STR_NULL;
        str attrs = STR_NULL;
+       str *output = NULL;
        str *outattrs = NULL;
 
        if ((idp = select_dpid(dpid)) ==0) {
@@ -491,16 +492,19 @@ static int dp_replace_helper(sip_msg_t *msg, int dpid, str *input,
        }
 
        outattrs = (!attr_pvar)?NULL:&attrs;
-       if (dp_translate_helper(msg, input, &output, idp, outattrs)!=0) {
+       output = (!pvd)?NULL:&tmp;
+       if (dp_translate_helper(msg, input, output, idp, outattrs)!=0) {
                LM_DBG("could not translate %.*s "
                                "with dpid %i\n", input->len, input->s, idp->dp_id);
                return -1;
        }
-       LM_DBG("input %.*s with dpid %i => output %.*s\n",
-                       input->len, input->s, idp->dp_id, output.len, output.s);
+       if (output) {
+               LM_DBG("input %.*s with dpid %i => output %.*s\n",
+                               input->len, input->s, idp->dp_id, output->len, output->s);
+       }
 
        /* set the output */
-       if (dp_update(msg, pvd, &output, outattrs) !=0){
+       if (dp_update(msg, pvd, output, outattrs) !=0){
                LM_ERR("cannot set the output\n");
                return -1;
        }
index 06534a9..05949c8 100644 (file)
@@ -699,6 +699,9 @@ repl:
                                        attrs->len, attrs->s);
                }
        }
+       if(!output) {
+               return 0;
+       }
        if(rulep->tflags&DP_TFLAGS_PV_SUBST) {
                re_list = dpl_dynamic_pcre_list(msg, &rulep->subst_exp);
                if(re_list==NULL) {