]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_if: Fix next priority calculation.
authorNaveen Albert <asterisk@phreaknet.org>
Sun, 28 Jan 2024 13:57:47 +0000 (08:57 -0500)
committerNaveen Albert <asterisk@phreaknet.org>
Tue, 30 Jan 2024 20:05:34 +0000 (20:05 +0000)
Commit fa3922a4d28860d415614347d9f06c233d2beb07 fixed
a branching issue but "overshoots" when calculating
the next priority. This fixes that; accompanying
test suite tests have also been extended.

Resolves: #560

apps/app_if.c

index 94bb1f12733ac81731f7f4748ebd55adfb54a663..81eda70224fa9cb186036960ff1d5fc1234a242d 100644 (file)
@@ -286,9 +286,11 @@ static int if_helper(struct ast_channel *chan, const char *data, int end)
                snprintf(end_varname,sizeof(end_varname),"END_%s",varname);
                ast_channel_lock(chan);
                /* For EndIf, simply go to the next priority.
+                * We do not add 1 to ast_channel_priority because the dialplan will
+                * auto-increment the priority when we return, so just keep the priority as is.
                 * 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);
+               endifpri = end == 2 ? ast_channel_priority(chan) : find_matching_endif(chan, NULL);
                if ((goto_str = pbx_builtin_getvar_helper(chan, end_varname))) {
                        ast_parseable_goto(chan, goto_str);
                        pbx_builtin_setvar_helper(chan, end_varname, NULL);