Browse code

core: kemi - parse headers before insert operation

Daniel-Constantin Mierla authored on 28/04/2021 14:06:50
Showing 1 changed files
... ...
@@ -2143,6 +2143,11 @@ static int sr_kemi_hdr_insert(sip_msg_t *msg, str *txt)
2143 2143
 	if(txt==NULL || txt->s==NULL || msg==NULL)
2144 2144
 		return -1;
2145 2145
 
2146
+	if ((parse_headers(msg, HDR_EOH_F, 0) == -1) || (msg->headers == NULL)) {
2147
+		LM_ERR("error while parsing message\n");
2148
+		return -1;
2149
+	}
2150
+
2146 2151
 	LM_DBG("insert hf: %.*s\n", txt->len, txt->s);
2147 2152
 	hdr = (char*)pkg_malloc(txt->len);
2148 2153
 	if(hdr==NULL) {
... ...
@@ -2188,7 +2193,7 @@ static int sr_kemi_hdr_insert_before(sip_msg_t *msg, str *txt, str *hname)
2188 2193
 		return -1;
2189 2194
 	}
2190 2195
 
2191
-	if (parse_headers(msg, HDR_EOH_F, 0) == -1) {
2196
+	if ((parse_headers(msg, HDR_EOH_F, 0) == -1) || (msg->headers == NULL)) {
2192 2197
 		LM_ERR("error while parsing message\n");
2193 2198
 		return -1;
2194 2199
 	}