Browse code

uac_redirect: check if reason parameter ifs provided for get_redirects()

- cope properly with the common function used for the two function
variants
- GH #3197

(cherry picked from commit 3b1354e2fd26c06fa6bc5ddbee1a012507aa2ea5)

Daniel-Constantin Mierla authored on 12/08/2022 07:16:24
Showing 1 changed files
... ...
@@ -344,17 +344,19 @@ static int w_get_redirect2(struct sip_msg* msg, char *max_c, char *reason)
344 344
 {
345 345
 	int n;
346 346
 	unsigned short max;
347
-	str sreason;
347
+	str sreason = {0};
348 348
 
349
-	if(fixup_get_svalue(msg, (gparam_t*)reason, &sreason)<0) {
350
-		LM_ERR("failed to get reason parameter\n");
351
-		return -1;
349
+	if(reason!=NULL) {
350
+		if(fixup_get_svalue(msg, (gparam_t*)reason, &sreason)<0) {
351
+			LM_ERR("failed to get reason parameter\n");
352
+			return -1;
353
+		}
352 354
 	}
353 355
 
354 356
 	msg_tracer( msg, 0);
355 357
 	/* get the contacts */
356 358
 	max = (unsigned short)(long)max_c;
357
-	n = get_redirect(msg , (max>>8)&0xff, max&0xff, &sreason, bflags);
359
+	n = get_redirect(msg , (max>>8)&0xff, max&0xff, (reason)?&sreason:NULL, bflags);
358 360
 	reset_filters();
359 361
 	/* reset the tracer */
360 362
 	msg_tracer( msg, 1);