diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-04 04:33:00 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-04 04:33:00 +0000 |
commit | 2cbe2541714610b48da826173b73dd72aa7f7e62 (patch) | |
tree | 49fd53d1adbc385a81bd70700375fbceb3278a31 /funcs | |
parent | 77ea45a5e15e3cecb712a1ab89008cfbc4d9052f (diff) |
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: http://svn.digium.com/svn/asterisk/branches/1.4@49388 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_realtime.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c index 9610c0c2a..cab52a588 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); |