aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_strings.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-14 19:06:44 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-14 19:06:44 +0000
commit0eb552742489bf71808edddcd83f98ff8e545f03 (patch)
tree632438c4c1d6ba3dec1d8cd0ee8b49a36ad31a85 /funcs/func_strings.c
parentab7169e673554eb53c65688eb1cbd4001e149473 (diff)
Bug 6238 - Fix segfault when delimiter not specified
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@8074 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_strings.c')
-rw-r--r--funcs/func_strings.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index 91564d9e4..503611bbe 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -48,8 +48,12 @@ static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data,
if (delim) {
varname = strsep(&delim, "|");
pbx_retrieve_variable(chan, varname, &varval, workspace, sizeof(workspace), NULL);
- while (strsep(&varval, delim))
- fieldcount++;
+ if (delim) {
+ while (strsep(&varval, delim))
+ fieldcount++;
+ } else if (!ast_strlen_zero(varval)) {
+ fieldcount = 1;
+ }
snprintf(buf, len, "%d", fieldcount);
} else {
ast_log(LOG_ERROR, "Out of memory\n");