app_if: Fix faulty EndIf branching.
This fixes faulty branching logic for the EndIf application. Instead of computing the next priority, which should be done for false conditionals or ExitIf, we should simply advance to the next priority. Resolves: #341
This commit is contained in:
parent
d6245bcfa3
commit
f4edb3b87e
|
@ -196,6 +196,7 @@ static int find_matching_endif(struct ast_channel *chan, const char *otherapp)
|
||||||
if (!ast_rdlock_context(c)) {
|
if (!ast_rdlock_context(c)) {
|
||||||
if (!strcmp(ast_get_context_name(c), ast_channel_context(chan))) {
|
if (!strcmp(ast_get_context_name(c), ast_channel_context(chan))) {
|
||||||
/* This is the matching context we want */
|
/* This is the matching context we want */
|
||||||
|
|
||||||
int cur_priority = ast_channel_priority(chan) + 1, level = 1;
|
int cur_priority = ast_channel_priority(chan) + 1, level = 1;
|
||||||
|
|
||||||
for (e = find_matching_priority(c, ast_channel_exten(chan), cur_priority,
|
for (e = find_matching_priority(c, ast_channel_exten(chan), cur_priority,
|
||||||
|
@ -203,6 +204,7 @@ static int find_matching_endif(struct ast_channel *chan, const char *otherapp)
|
||||||
e;
|
e;
|
||||||
e = find_matching_priority(c, ast_channel_exten(chan), ++cur_priority,
|
e = find_matching_priority(c, ast_channel_exten(chan), ++cur_priority,
|
||||||
S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
|
S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
|
||||||
|
|
||||||
if (!strcasecmp(ast_get_extension_app(e), "IF")) {
|
if (!strcasecmp(ast_get_extension_app(e), "IF")) {
|
||||||
level++;
|
level++;
|
||||||
} else if (!strcasecmp(ast_get_extension_app(e), "ENDIF")) {
|
} else if (!strcasecmp(ast_get_extension_app(e), "ENDIF")) {
|
||||||
|
@ -283,7 +285,10 @@ static int if_helper(struct ast_channel *chan, const char *data, int end)
|
||||||
pbx_builtin_setvar_helper(chan, my_name, NULL);
|
pbx_builtin_setvar_helper(chan, my_name, NULL);
|
||||||
snprintf(end_varname,sizeof(end_varname),"END_%s",varname);
|
snprintf(end_varname,sizeof(end_varname),"END_%s",varname);
|
||||||
ast_channel_lock(chan);
|
ast_channel_lock(chan);
|
||||||
endifpri = find_matching_endif(chan, NULL);
|
/* For EndIf, simply go to the next priority.
|
||||||
|
* For ExitIf or false If() condition, we need to find the end of the current
|
||||||
|
* If branch (at same indentation) and branch there. */
|
||||||
|
endifpri = end == 2 ? ast_channel_priority(chan) + 1 : find_matching_endif(chan, NULL);
|
||||||
if ((goto_str = pbx_builtin_getvar_helper(chan, end_varname))) {
|
if ((goto_str = pbx_builtin_getvar_helper(chan, end_varname))) {
|
||||||
ast_parseable_goto(chan, goto_str);
|
ast_parseable_goto(chan, goto_str);
|
||||||
pbx_builtin_setvar_helper(chan, end_varname, NULL);
|
pbx_builtin_setvar_helper(chan, end_varname, NULL);
|
||||||
|
|
Loading…
Reference in New Issue