From c253d41d757f3e077a9ce8daaff816dd3b7f4807 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 21 Apr 2009 17:41:54 +0000 Subject: [PATCH] fix arg parsing in new command git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13102 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/applications/mod_commands/mod_commands.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index d81ff925e1..65ea73b275 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -532,6 +532,11 @@ SWITCH_STANDARD_API(expand_function) switch_core_session_t *xsession; char uuid[80] = ""; + if (switch_strlen_zero(cmd)) { + stream->write_function(stream, "-ERR, no input\n"); + return SWITCH_STATUS_SUCCESS; + } + dup = strdup(cmd); mycmd = dup; @@ -558,8 +563,10 @@ SWITCH_STANDARD_API(expand_function) *arg++ = '\0'; } - expanded = switch_event_expand_headers(stream->param_event, arg); - status = switch_api_execute(mycmd, expanded, session, stream); + expanded = arg ? switch_event_expand_headers(stream->param_event, arg) : arg; + if ((status = switch_api_execute(mycmd, expanded, session, stream)) != SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "-ERR, error executing command\n"); + } if (expanded != arg) { free(expanded); @@ -569,7 +576,7 @@ SWITCH_STANDARD_API(expand_function) free(dup); dup = NULL; - return status; + return SWITCH_STATUS_SUCCESS; }