fix seg in new function

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8083 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-04-10 15:42:13 +00:00
parent 46c3aab5c8
commit f758a24f2e
1 changed files with 11 additions and 0 deletions

View File

@ -673,6 +673,12 @@ SWITCH_STANDARD_API(enum_api)
switch_size_t l = 0, rbl = sizeof(rbuf); switch_size_t l = 0, rbl = sizeof(rbuf);
int last_order = -1, last_pref = -2; int last_order = -1, last_pref = -2;
char *last_delim = "|"; char *last_delim = "|";
int ok = 0;
if (switch_strlen_zero(cmd)) {
stream->write_function(stream, "%s", "none");
return SWITCH_STATUS_SUCCESS;
}
if (!(mydata = strdup(cmd))) { if (!(mydata = strdup(cmd))) {
abort(); abort();
@ -701,11 +707,16 @@ SWITCH_STANDARD_API(enum_api)
*(rbuf + strlen(rbuf) - 1) = '\0'; *(rbuf + strlen(rbuf) - 1) = '\0';
stream->write_function(stream, "%s", rbuf); stream->write_function(stream, "%s", rbuf);
free_results(&results); free_results(&results);
ok++;
} }
} }
switch_safe_free(mydata); switch_safe_free(mydata);
if (!ok) {
stream->write_function(stream, "%s", "none");
}
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }