diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-17 16:45:42 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-17 16:45:42 +0000 |
commit | 8508675ead68477a4b558b4b1dafa141381122f9 (patch) | |
tree | 1eae1a571cd813509f0b3f240f7a36fac67c22e3 /funcs | |
parent | be1abf627557eebd2a2dfe5dd7fb6e748638e60e (diff) |
prevent copying of NULL (bug #4307)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5708 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rwxr-xr-x | funcs/func_logic.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/funcs/func_logic.c b/funcs/func_logic.c index d20b7719f..8df1732ba 100755 --- a/funcs/func_logic.c +++ b/funcs/func_logic.c @@ -52,12 +52,14 @@ static char *builtin_function_if(struct ast_channel *chan, char *cmd, char *data *iffalse = '\0'; iffalse++; } - } else - iffalse = ""; + } + if (expr && iftrue) { ret = ast_true(expr) ? iftrue : iffalse; - strncpy(buf, ret, len); - ret = buf; + if (ret) { + ast_copy_string(buf, ret, len); + ret = buf; + } } else { ast_log(LOG_WARNING, "Syntax $(if <expr>?[<truecond>][:<falsecond>])\n"); ret = NULL; |