Assert the size of EVENT_NAMES at initialization

This commit is contained in:
Mathieu Rene 2010-06-07 08:49:04 -04:00
parent 5cd066df39
commit 114731215d
1 changed files with 3 additions and 1 deletions

View File

@ -385,7 +385,7 @@ SWITCH_DECLARE(switch_status_t) switch_name_event(const char *name, switch_event
switch_assert(RUNTIME_POOL != NULL); switch_assert(RUNTIME_POOL != NULL);
for (x = 0; x <= SWITCH_EVENT_ALL; x++) { for (x = 0; x <= SWITCH_EVENT_ALL; x++) {
if ((strlen(name) > 13 && x < switch_arraylen(EVENT_NAMES) && !strcasecmp(name + 13, EVENT_NAMES[x])) || !strcasecmp(name, EVENT_NAMES[x])) { if ((strlen(name) > 13 && !strcasecmp(name + 13, EVENT_NAMES[x])) || !strcasecmp(name, EVENT_NAMES[x])) {
*type = x; *type = x;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -580,6 +580,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
{ {
switch_threadattr_t *thd_attr;; switch_threadattr_t *thd_attr;;
switch_assert(switch_arraylen(EVENT_NAMES) == SWITCH_EVENT_ALL + 1);
switch_assert(pool != NULL); switch_assert(pool != NULL);
THRUNTIME_POOL = RUNTIME_POOL = pool; THRUNTIME_POOL = RUNTIME_POOL = pool;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Eventing Engine.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Eventing Engine.\n");