From 870f98f02de56e35b87f511544a6cda3d4d8fe69 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Sat, 3 Dec 2005 19:25:33 +0000 Subject: Bug 5858 - Make the chanvars.c functions return a 'const char *' This should prevent us from unintentionally changing variable values when they're returned from pbx_builtin_getvar_helper. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7304 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_while.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'apps/app_while.c') diff --git a/apps/app_while.c b/apps/app_while.c index 7c98afe80..1c91446aa 100644 --- a/apps/app_while.c +++ b/apps/app_while.c @@ -122,7 +122,7 @@ static int execif_exec(struct ast_channel *chan, void *data) { #define VAR_SIZE 64 -static char *get_index(struct ast_channel *chan, const char *prefix, int index) { +static const char *get_index(struct ast_channel *chan, const char *prefix, int index) { char varname[VAR_SIZE]; snprintf(varname, VAR_SIZE, "%s_%d", prefix, index); @@ -209,15 +209,15 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) { int res=0; struct localuser *u; - char *while_pri = NULL; - char *goto_str = NULL, *my_name = NULL; - char *condition = NULL, *label = NULL; + const char *while_pri = NULL; + char *my_name = NULL; + const char *condition = NULL, *label = NULL; char varname[VAR_SIZE], end_varname[VAR_SIZE]; const char *prefix = "WHILE"; size_t size=0; int used_index_i = -1, x=0; char used_index[VAR_SIZE] = "0", new_index[VAR_SIZE] = "0"; - + if (!chan) { /* huh ? */ return -1; @@ -271,6 +271,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) if (!end && !ast_true(condition)) { /* Condition Met (clean up helper vars) */ + const char *goto_str; pbx_builtin_setvar_helper(chan, varname, NULL); pbx_builtin_setvar_helper(chan, my_name, NULL); snprintf(end_varname,VAR_SIZE,"END_%s",varname); @@ -291,6 +292,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) } if (!end && !while_pri) { + char *goto_str; size = strlen(chan->context) + strlen(chan->exten) + 32; goto_str = alloca(size); memset(goto_str, 0, size); @@ -302,6 +304,7 @@ static int _while_exec(struct ast_channel *chan, void *data, int end) /* END of loop */ snprintf(end_varname, VAR_SIZE, "END_%s", varname); if (! pbx_builtin_getvar_helper(chan, end_varname)) { + char *goto_str; size = strlen(chan->context) + strlen(chan->exten) + 32; goto_str = alloca(size); memset(goto_str, 0, size); -- cgit v1.2.3