From 114731215dcd8e9b5cfe55c68b318a27bc086d8c Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Mon, 7 Jun 2010 08:49:04 -0400 Subject: [PATCH] Assert the size of EVENT_NAMES at initialization --- src/switch_event.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/switch_event.c b/src/switch_event.c index e572cf42fe..0f9f60a1d1 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -385,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 && 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; 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_assert(switch_arraylen(EVENT_NAMES) == SWITCH_EVENT_ALL + 1); + switch_assert(pool != NULL); THRUNTIME_POOL = RUNTIME_POOL = pool; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Eventing Engine.\n");