Index: pbx/pbx_realtime.c =================================================================== --- pbx/pbx_realtime.c (revision 334227) +++ pbx/pbx_realtime.c (working copy) @@ -68,6 +68,8 @@ AST_APP_OPTION('p', OPTION_PATTERNS_DISABLED), }); +AST_THREADSTORAGE(appdata_buf); + struct cache_entry { struct timeval when; struct ast_variable *var; @@ -344,19 +346,23 @@ if (!ast_strlen_zero(app)) { struct ast_app *a = pbx_findapp(app); if (a) { - char appdata[512]; + struct ast_str *appdata = ast_str_thread_get(&appdata_buf, 16); char tmp1[80]; char tmp2[80]; char tmp3[EXT_DATA_SIZE]; - appdata[0] = 0; /* just in case the substitute var func isn't called */ - if(!ast_strlen_zero(tmp)) - pbx_substitute_variables_helper(chan, tmp, appdata, sizeof(appdata) - 1); + if (!appdata) { + return -1; + } + ast_str_reset(appdata); /* just in case the substitute var func isn't called */ + if (!ast_strlen_zero(tmp)) { + ast_str_substitute_variables(&appdata, 0, chan, tmp); + } ast_verb(3, "Executing [%s@%s:%d] %s(\"%s\", \"%s\")\n", chan->exten, chan->context, chan->priority, term_color(tmp1, app, COLOR_BRCYAN, 0, sizeof(tmp1)), term_color(tmp2, chan->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)), - term_color(tmp3, S_OR(appdata, ""), COLOR_BRMAGENTA, 0, sizeof(tmp3))); + term_color(tmp3, ast_str_buffer(appdata), COLOR_BRMAGENTA, 0, sizeof(tmp3))); manager_event(EVENT_FLAG_DIALPLAN, "Newexten", "Channel: %s\r\n" "Context: %s\r\n" @@ -365,9 +371,9 @@ "Application: %s\r\n" "AppData: %s\r\n" "Uniqueid: %s\r\n", - chan->name, chan->context, chan->exten, chan->priority, app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", chan->uniqueid); - - res = pbx_exec(chan, a, appdata); + chan->name, chan->context, chan->exten, chan->priority, app, ast_str_buffer(appdata), chan->uniqueid); + + res = pbx_exec(chan, a, ast_str_buffer(appdata)); } else ast_log(LOG_NOTICE, "No such application '%s' for extension '%s' in context '%s'\n", app, exten, context); } else {