Browse code

core: ppcfg - clone value for substdef

- GH #2788

(cherry picked from commit 56d41f6238f39d0046c97527abcb23b8dd7924be)

Daniel-Constantin Mierla authored on 01/07/2021 08:19:08
Showing 1 changed files
... ...
@@ -30,6 +30,7 @@
30 30
 #include "ut.h"
31 31
 #include "re.h"
32 32
 #include "pvar.h"
33
+#include "str_list.h"
33 34
 #include "dprint.h"
34 35
 
35 36
 #include "ppcfg.h"
... ...
@@ -44,6 +45,7 @@ typedef struct _pp_subst_rule {
44 45
 static pp_subst_rule_t *pp_subst_rules_head = NULL;
45 46
 static pp_subst_rule_t *pp_subst_rules_tail = NULL;
46 47
 static int _pp_ifdef_level = 0;
48
+static str_list_t *_ksr_substdef_strlist = NULL;
47 49
 
48 50
 int pp_subst_add(char *data)
49 51
 {
... ...
@@ -94,6 +96,7 @@ int pp_substdef_add(char *data, int mode)
94 96
 	str defvalue;
95 97
 	str newval;
96 98
 	sip_msg_t *fmsg;
99
+	str_list_t *sb;
97 100
 
98 101
 	if(pp_subst_add(data)<0) {
99 102
 		LM_ERR("subst rule cannot be added\n");
... ...
@@ -146,7 +149,12 @@ found_repl:
146 149
 	if(memchr(defvalue.s, '$', defvalue.len) != NULL) {
147 150
 		fmsg = faked_msg_get_next();
148 151
 		if(pv_eval_str(fmsg, &newval, &defvalue)>=0) {
149
-			defvalue = newval;
152
+			sb = str_list_block_add(&_ksr_substdef_strlist, newval.s, newval.len);
153
+			if(sb==NULL) {
154
+				LM_ERR("failed to handle substdef: [%s]\n", data);
155
+				return -1;
156
+			}
157
+			defvalue = sb->s;
150 158
 		}
151 159
 	}
152 160
 	if(pp_define_set(defvalue.len, defvalue.s,