Browse code

core: clone values for defines

Daniel-Constantin Mierla authored on 20/09/2022 09:01:56
Showing 1 changed files
... ...
@@ -2144,8 +2144,17 @@ int pp_define_set(int len, char *text, int mode)
2144 2144
 		return -1;
2145 2145
 	}
2146 2146
 
2147
+	pp_defines[ppos].value.s = (char*)pkg_malloc(len+1);
2148
+	if (pp_defines[ppos].value.s == NULL) {
2149
+		LM_ERR("no more memory to define %.*s [%d]\n",
2150
+			pp_defines[ppos].name.len,
2151
+			pp_defines[ppos].name.s, ppos);
2152
+		return -1;
2153
+	}
2154
+
2155
+	memcpy(pp_defines[ppos].value.s, text, len);
2156
+	pp_defines[ppos].value.s[len] = '\0';
2147 2157
 	pp_defines[ppos].value.len = len;
2148
-	pp_defines[ppos].value.s = text;
2149 2158
 	LM_DBG("### setting define ID [%.*s] value [%.*s] (mode: %d)\n",
2150 2159
 			pp_defines[ppos].name.len,
2151 2160
 			pp_defines[ppos].name.s,