mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-18 15:49:56 +00:00
bring justice to gotoif's always true bug
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3372 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
25
pbx.c
25
pbx.c
@@ -4588,19 +4588,7 @@ void pbx_builtin_clear_globals(void)
|
|||||||
|
|
||||||
static int pbx_checkcondition(char *condition)
|
static int pbx_checkcondition(char *condition)
|
||||||
{
|
{
|
||||||
char *s;
|
return condition ? atoi(condition) : 0;
|
||||||
int ret;
|
|
||||||
|
|
||||||
s=strdup(condition);
|
|
||||||
|
|
||||||
ret=1;
|
|
||||||
|
|
||||||
if ((strcasecmp(s,"0")) || ast_strlen_zero(s)) {
|
|
||||||
ret=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(s);
|
|
||||||
return(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
|
static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
|
||||||
@@ -4615,17 +4603,12 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s=strdup(data);
|
s=ast_strdupa(data);
|
||||||
stringp=s;
|
stringp=s;
|
||||||
condition=strsep(&stringp,"?");
|
condition=strsep(&stringp,"?");
|
||||||
branch1=strsep(&stringp,":");
|
branch1=strsep(&stringp,":");
|
||||||
branch2=strsep(&stringp,"");
|
branch2=strsep(&stringp,"");
|
||||||
|
branch = pbx_checkcondition(condition) ? branch1 : branch2;
|
||||||
if (pbx_checkcondition(condition)) {
|
|
||||||
branch=branch2;
|
|
||||||
} else {
|
|
||||||
branch=branch1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((branch==NULL) || ast_strlen_zero(branch)) {
|
if ((branch==NULL) || ast_strlen_zero(branch)) {
|
||||||
ast_log(LOG_NOTICE, "Not taking any branch\n");
|
ast_log(LOG_NOTICE, "Not taking any branch\n");
|
||||||
@@ -4633,7 +4616,7 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc=pbx_builtin_goto(chan,branch);
|
rc=pbx_builtin_goto(chan,branch);
|
||||||
free(s);
|
|
||||||
return(rc);
|
return(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user