aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/app_stack.c')
-rw-r--r--apps/app_stack.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/apps/app_stack.c b/apps/app_stack.c
index 92a0e0d74..eae4a1dfd 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -373,8 +373,9 @@ static int gosub_exec(struct ast_channel *chan, void *data)
/* Create the return address, but don't save it until we know that the Gosub destination exists */
newframe = gosub_allocate_frame(chan->context, chan->exten, chan->priority + 1, args2.argc);
- if (!newframe)
+ if (!newframe) {
return -1;
+ }
if (ast_parseable_goto(chan, label)) {
ast_log(LOG_ERROR, "Gosub address is invalid: '%s'\n", (char *)data);
@@ -382,6 +383,16 @@ static int gosub_exec(struct ast_channel *chan, void *data)
return -1;
}
+ if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+ ast_log(LOG_ERROR, "Attempt to reach a non-existent destination for gosub: (Context:%s, Extension:%s, Priority:%d)\n",
+ chan->context, chan->exten, chan->priority);
+ ast_copy_string(chan->context, newframe->context, sizeof(chan->context));
+ ast_copy_string(chan->exten, newframe->extension, sizeof(chan->exten));
+ chan->priority = newframe->priority;
+ ast_free(newframe);
+ return -1;
+ }
+
/* Now that we know for certain that we're going to a new location, set our arguments */
for (i = 0; i < args2.argc; i++) {
snprintf(argname, sizeof(argname), "ARG%d", i + 1);