From 525f5e6d755fb460cc19a6d78177415b769224ea Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 4 Jan 2007 04:33:00 +0000 Subject: [PATCH] Fix the REALTIME() dialplan function. ast_build_string() advances the string pointer to the position to begin the next write into the buffer. So, this pointer can not be used to copy the contents of the string later. The beginning of the buffer must be saved. Interestingly enough, this code could not have ever worked. (Pointed out by Sebb on IRC, thanks!) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@49388 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_realtime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c index 9610c0c2a3..cab52a5883 100644 --- a/funcs/func_realtime.c +++ b/funcs/func_realtime.c @@ -49,7 +49,7 @@ static int function_realtime_read(struct ast_channel *chan, char *cmd, char *dat { struct ast_variable *var, *head; struct ast_module_user *u; - char *results; + char *results, *result_begin; size_t resultslen = 0; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(family); @@ -83,10 +83,10 @@ static int function_realtime_read(struct ast_channel *chan, char *cmd, char *dat for (var = head; var; var = var->next) resultslen += strlen(var->name) + strlen(var->value) + 2; - results = alloca(resultslen); + result_begin = results = alloca(resultslen); for (var = head; var; var = var->next) ast_build_string(&results, &resultslen, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1); - ast_copy_string(buf, results, len); + ast_copy_string(buf, result_begin, len); ast_module_user_remove(u);