fix issue reported on mailing list along with segfault.

This commit is contained in:
Brian West 2010-06-06 23:26:09 -05:00
parent 35301c0fa5
commit 5cd066df39
2 changed files with 5 additions and 1 deletions

View File

@ -76,6 +76,8 @@ static const char *EVENT_NAMES[] = {
"CHANNEL_PARK",
"CHANNEL_UNPARK",
"CHANNEL_APPLICATION",
"CHANNEL_HOLD",
"CHANNEL_UNHOLD",
"CHANNEL_ORIGINATE",
"CHANNEL_UUID",
"API",

View File

@ -132,6 +132,8 @@ static char *EVENT_NAMES[] = {
"CHANNEL_PARK",
"CHANNEL_UNPARK",
"CHANNEL_APPLICATION",
"CHANNEL_HOLD",
"CHANNEL_UNHOLD",
"CHANNEL_ORIGINATE",
"CHANNEL_UUID",
"API",
@ -383,7 +385,7 @@ SWITCH_DECLARE(switch_status_t) switch_name_event(const char *name, switch_event
switch_assert(RUNTIME_POOL != NULL);
for (x = 0; x <= SWITCH_EVENT_ALL; x++) {
if ((strlen(name) > 13 && !strcasecmp(name + 13, EVENT_NAMES[x])) || !strcasecmp(name, EVENT_NAMES[x])) {
if ((strlen(name) > 13 && x < switch_arraylen(EVENT_NAMES) && !strcasecmp(name + 13, EVENT_NAMES[x])) || !strcasecmp(name, EVENT_NAMES[x])) {
*type = x;
return SWITCH_STATUS_SUCCESS;
}