summaryrefslogtreecommitdiff
path: root/pbx.c
diff options
context:
space:
mode:
authorAnthony Minessale II <anthmct@yahoo.com>2004-12-08 18:24:04 +0000
committerAnthony Minessale II <anthmct@yahoo.com>2004-12-08 18:24:04 +0000
commit8708f19e39b852b84b1283d2e6b5e361b29dc89d (patch)
treea4147415ab586491b7feab52530ee9302a6dd49f /pbx.c
parentab7bf9d4fd614d302b855b12fa0b59f76c69355e (diff)
fix bug 2994 (off by 1 error)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4404 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx.c')
-rwxr-xr-xpbx.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/pbx.c b/pbx.c
index 5062e97c0..f7b025d9a 100755
--- a/pbx.c
+++ b/pbx.c
@@ -3837,8 +3837,8 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char
strncpy(chan->context, context, sizeof(chan->context) - 1);
if (exten && !ast_strlen_zero(exten))
strncpy(chan->exten, exten, sizeof(chan->context) - 1);
- if (priority)
- chan->priority = priority;
+ if(priority > -1)
+ chan->priority = priority;
return 0;
}
return -1;
@@ -3869,7 +3869,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
ast_explicit_goto(tmpchan,
(context && !ast_strlen_zero(context)) ? context : chan->context,
(exten && !ast_strlen_zero(exten)) ? exten : chan->exten,
- priority ? priority : chan->priority);
+ priority - 1);
/* Masquerade into temp channel */
ast_channel_masquerade(tmpchan, chan);
@@ -5420,18 +5420,28 @@ int ast_context_verify_includes(struct ast_context *con)
static int __ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority, int async)
{
- int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority) = async ? ast_async_goto : ast_explicit_goto;
+ int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority) = NULL;
if(chan) {
- if(ast_exists_extension(chan,
- context ? context : chan->context,
- exten ? exten : chan->exten,
- priority ? priority : chan->priority,
- chan->cid.cid_num)) {
+
+ if (async) {
+ goto_func = ast_async_goto;
+ } else {
+ goto_func = ast_explicit_goto;
+ priority--;
+ if(priority < 0)
+ priority = 0;
+ }
+
+ if (ast_exists_extension(chan,
+ context ? context : chan->context,
+ exten ? exten : chan->exten,
+ priority,
+ chan->cid.cid_num)) {
return goto_func(chan,
- context ? context : chan->context,
- exten ? exten : chan->exten,
- (priority ? priority : chan->priority) - 1);
+ context ? context : chan->context,
+ exten ? exten : chan->exten,
+ priority);
} else
return -3;
}
@@ -5501,12 +5511,7 @@ int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
ipri = chan->priority + (ipri * mode);
/* This channel is currently in the PBX */
- if (context && !ast_strlen_zero(context))
- strncpy(chan->context, context, sizeof(chan->context) - 1);
- if (exten && !ast_strlen_zero(exten))
- strncpy(chan->exten, exten, sizeof(chan->context) - 1);
- chan->priority = ipri - 1;
-
+ ast_explicit_goto(chan, context, exten, ipri - 1);
ast_cdr_update(chan);
return 0;