--- app_macro.old.c 2008-12-24 01:52:12.000000000 +0100 +++ app_macro.c 2009-07-31 14:14:56.000000000 +0200 @@ -454,6 +454,23 @@ chan->macropriority = 0; } + /*!\note + * This section is used to restore a behavior that we mistakenly + * changed in issue #6176, then mistakenly reverted in #13962 and + * #13363. A corresponding change is made in main/pbx.c, where we + * check this variable for existence, then look for the "h" extension + * in that context. + */ + if (ast_check_hangup(chan) || res < 0) { + /* Don't need to lock the channel, as we aren't dereferencing emc. + * The intent here is to grab the deepest context, without overwriting + * in any above context. */ + const char *emc = pbx_builtin_getvar_helper(chan, "EXIT_MACRO_CONTEXT"); + if (!emc) { + pbx_builtin_setvar_helper(chan, "EXIT_MACRO_CONTEXT", fullmacro); + } + } + if (!strcasecmp(chan->context, fullmacro)) { /* If we're leaving the macro normally, restore original information */ chan->priority = oldpriority;