mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
When we call a gosub routine, the variables should be scoped to avoid contaminating the caller.
This affected the ~~EXTEN~~ hack, where a subroutine might have changed the value before it was used in the caller. Patch by myself, tested by ebroad on #asterisk git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@222273 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3361,6 +3361,7 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
|
|||||||
if (contains_switch(statement)) { /* only run contains_switch if you haven't checked before */
|
if (contains_switch(statement)) { /* only run contains_switch if you haven't checked before */
|
||||||
if (mother_exten) {
|
if (mother_exten) {
|
||||||
if (!mother_exten->has_switch) {
|
if (!mother_exten->has_switch) {
|
||||||
|
for (first = 1; first >= 0; first--) {
|
||||||
switch_set = new_prio();
|
switch_set = new_prio();
|
||||||
switch_set->type = AEL_APPCALL;
|
switch_set->type = AEL_APPCALL;
|
||||||
if (!ast_compat_app_set) {
|
if (!ast_compat_app_set) {
|
||||||
@@ -3368,7 +3369,16 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
|
|||||||
} else {
|
} else {
|
||||||
switch_set->app = strdup("Set");
|
switch_set->app = strdup("Set");
|
||||||
}
|
}
|
||||||
|
/* Are we likely inside a gosub subroutine? */
|
||||||
|
if (!strcmp(mother_exten->name, "s") && first) {
|
||||||
|
/* If we're not actually within a gosub, this will fail, but the
|
||||||
|
* second time through, it will get set. If we are within gosub,
|
||||||
|
* the second time through is redundant, but acceptable. */
|
||||||
|
switch_set->appargs = strdup("LOCAL(~~EXTEN~~)=${EXTEN}");
|
||||||
|
} else {
|
||||||
switch_set->appargs = strdup("~~EXTEN~~=${EXTEN}");
|
switch_set->appargs = strdup("~~EXTEN~~=${EXTEN}");
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
linkprio(exten, switch_set, mother_exten);
|
linkprio(exten, switch_set, mother_exten);
|
||||||
mother_exten->has_switch = 1;
|
mother_exten->has_switch = 1;
|
||||||
mother_exten->checked_switch = 1;
|
mother_exten->checked_switch = 1;
|
||||||
@@ -3377,8 +3387,10 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
|
|||||||
exten->checked_switch = 1;
|
exten->checked_switch = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (exten) {
|
} else if (exten) {
|
||||||
if (!exten->has_switch) {
|
if (!exten->has_switch) {
|
||||||
|
for (first = 1; first >= 0; first--) {
|
||||||
switch_set = new_prio();
|
switch_set = new_prio();
|
||||||
switch_set->type = AEL_APPCALL;
|
switch_set->type = AEL_APPCALL;
|
||||||
if (!ast_compat_app_set) {
|
if (!ast_compat_app_set) {
|
||||||
@@ -3386,7 +3398,16 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
|
|||||||
} else {
|
} else {
|
||||||
switch_set->app = strdup("Set");
|
switch_set->app = strdup("Set");
|
||||||
}
|
}
|
||||||
|
/* Are we likely inside a gosub subroutine? */
|
||||||
|
if (!strcmp(exten->name, "s")) {
|
||||||
|
/* If we're not actually within a gosub, this will fail, but the
|
||||||
|
* second time through, it will get set. If we are within gosub,
|
||||||
|
* the second time through is redundant, but acceptable. */
|
||||||
|
switch_set->appargs = strdup("LOCAL(~~EXTEN~~)=${EXTEN}");
|
||||||
|
} else {
|
||||||
switch_set->appargs = strdup("~~EXTEN~~=${EXTEN}");
|
switch_set->appargs = strdup("~~EXTEN~~=${EXTEN}");
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
linkprio(exten, switch_set, mother_exten);
|
linkprio(exten, switch_set, mother_exten);
|
||||||
exten->has_switch = 1;
|
exten->has_switch = 1;
|
||||||
exten->checked_switch = 1;
|
exten->checked_switch = 1;
|
||||||
@@ -3396,6 +3417,7 @@ static void gen_prios(struct ael_extension *exten, char *label, pval *statement,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mother_exten) {
|
if (mother_exten) {
|
||||||
mother_exten->checked_switch = 1;
|
mother_exten->checked_switch = 1;
|
||||||
|
Reference in New Issue
Block a user