diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-29 21:49:35 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-29 21:49:35 +0000 |
commit | 38980142a4bec113ad225288a75f7358bc1e0780 (patch) | |
tree | 4d8b72b161c60bb8176b2cf8d127f0ffd5b3954f | |
parent | 20679196f8143c52409bc30870ec27bc48758e6e (diff) |
If the value of a variable passed to FIELDQTY is blank, then FIELDQTY should return 0, not 1.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@66537 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | funcs/func_strings.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/funcs/func_strings.c b/funcs/func_strings.c index 00b6dd172..0aaf3fc4b 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -51,7 +51,9 @@ static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data, sprintf(varsubst, "${%s}", varname); pbx_substitute_variables_helper(chan, varsubst, varval, sizeof(varval) - 1); - if (delim) { + if (ast_strlen_zero(varval)) + fieldcount = 0; + else if (delim) { while (strsep(&varval2, delim)) fieldcount++; } else if (!ast_strlen_zero(varval)) { @@ -60,7 +62,7 @@ static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data, snprintf(buf, len, "%d", fieldcount); } else { ast_log(LOG_ERROR, "Out of memory\n"); - strncpy(buf, "1", len); + ast_copy_string(buf, "1", len); } return buf; } |