diff options
author | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-01 20:42:49 +0000 |
---|---|---|
committer | anthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-07-01 20:42:49 +0000 |
commit | 66d644cb99e6232bc99f05d436c72dcb612fb26e (patch) | |
tree | 4a501af4af1ee21598d87c9b1b1d360fc71a65eb /pbx.c | |
parent | 1c7cb960b1974b637b3ab75c79d8d8281df06b5c (diff) |
bring justice to gotoif's always true bug
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3372 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rwxr-xr-x | pbx.c | 25 |
1 files changed, 4 insertions, 21 deletions
@@ -4588,19 +4588,7 @@ void pbx_builtin_clear_globals(void) static int pbx_checkcondition(char *condition) { - char *s; - int ret; - - s=strdup(condition); - - ret=1; - - if ((strcasecmp(s,"0")) || ast_strlen_zero(s)) { - ret=0; - } - - free(s); - return(ret); + return condition ? atoi(condition) : 0; } 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; } - s=strdup(data); + s=ast_strdupa(data); stringp=s; condition=strsep(&stringp,"?"); branch1=strsep(&stringp,":"); branch2=strsep(&stringp,""); - - if (pbx_checkcondition(condition)) { - branch=branch2; - } else { - branch=branch1; - } + branch = pbx_checkcondition(condition) ? branch1 : branch2; if ((branch==NULL) || ast_strlen_zero(branch)) { 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); - free(s); + return(rc); } |