From: Anthony Minessale Date: Mon, 5 Jun 2017 23:31:56 +0000 (-0500) Subject: FS-10189: [core] switch_core_add_state_handler runtime.state_handler_index may exceed... X-Git-Tag: v1.8.0~464 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a09c9cfa7ae87e9af3e033c2bcab3e97affddda1;p=thirdparty%2Ffreeswitch.git FS-10189: [core] switch_core_add_state_handler runtime.state_handler_index may exceed SWITCH_MAX_STATE_HANDLERS #resolve --- diff --git a/src/switch_core.c b/src/switch_core.c index 0b8c51f1f7..22b35ed63b 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -310,12 +310,13 @@ SWITCH_DECLARE(int) switch_core_add_state_handler(const switch_state_handler_tab int index; switch_mutex_lock(runtime.global_mutex); - index = runtime.state_handler_index++; + index = runtime.state_handler_index; - if (runtime.state_handler_index >= SWITCH_MAX_STATE_HANDLERS) { + if (index > (SWITCH_MAX_STATE_HANDLERS - 1)) { index = -1; } else { runtime.state_handlers[index] = state_handler; + runtime.state_handler_index++; } switch_mutex_unlock(runtime.global_mutex);