From 555bbffec3f57e8aa001728473df99eeb2cf107f Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Sat, 14 Jan 2006 19:06:44 +0000 Subject: [PATCH] Bug 6238 - Fix segfault when delimiter not specified git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@8074 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_strings.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/funcs/func_strings.c b/funcs/func_strings.c index 91564d9e48..503611bbe9 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");