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
This commit is contained in:
Russell Bryant
2007-01-04 04:33:00 +00:00
parent 5ebc820813
commit 525f5e6d75

View File

@@ -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);