Skip to content

Commit 47f56e0

Browse files
committed
[async] fix async launching without report route
Handle the case where no report route is provided. Closes OpenSIPS#3188 (cherry picked from commit 26d6d95)
1 parent fd06576 commit 47f56e0

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

async.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ int async_script_launch(struct sip_msg *msg, struct action* a,
295295
return -1;
296296
}
297297

298-
if ( (ctx=shm_malloc(sizeof(async_launch_ctx) + (report_route_param?report_route_param->len:0)))==NULL) {
298+
if ( (ctx=shm_malloc(sizeof(async_launch_ctx) + ( (report_route&&report_route_param)?report_route_param->len:0)))==NULL) {
299299
LM_ERR("failed to allocate new ctx, forcing sync mode\n");
300300
return -1;
301301
}
@@ -339,20 +339,22 @@ int async_script_launch(struct sip_msg *msg, struct action* a,
339339

340340
/* ctx is to be used from this point further */
341341

342-
ctx->report_route = dup_ref_script_route_in_shm( report_route, 0);
343-
if (!ref_script_route_is_valid(ctx->report_route)) {
344-
LM_ERR("failed dup resume route -> act in sync mode\n");
345-
goto sync;
346-
}
342+
if (report_route) {
343+
ctx->report_route = dup_ref_script_route_in_shm( report_route, 0);
344+
if (!ref_script_route_is_valid(ctx->report_route)) {
345+
LM_ERR("failed dup resume route -> act in sync mode\n");
346+
goto sync;
347+
}
347348

348-
if (report_route_param) {
349-
ctx->report_route_param.s = (char *)(ctx+1);
350-
ctx->report_route_param.len = report_route_param->len;
351-
memcpy(ctx->report_route_param.s, report_route_param->s,
352-
report_route_param->len);
353-
} else {
354-
ctx->report_route_param.s = NULL;
355-
ctx->report_route_param.len = 0;
349+
if (report_route_param) {
350+
ctx->report_route_param.s = (char *)(ctx+1);
351+
ctx->report_route_param.len = report_route_param->len;
352+
memcpy(ctx->report_route_param.s, report_route_param->s,
353+
report_route_param->len);
354+
} else {
355+
ctx->report_route_param.s = NULL;
356+
ctx->report_route_param.len = 0;
357+
}
356358
}
357359

358360
if (async_status!=ASYNC_NO_FD) {

0 commit comments

Comments
 (0)