Skip to content

Commit

Permalink
[Core] Fix race in switch_channel_get_state_handler()
Browse files Browse the repository at this point in the history
  • Loading branch information
andywolk committed Jul 31, 2024
1 parent cbe35ee commit 4ff9d35
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/switch_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -3072,11 +3072,13 @@ SWITCH_DECLARE(const switch_state_handler_table_t *) switch_channel_get_state_ha

switch_assert(channel != NULL);

switch_mutex_lock(channel->state_mutex);
if (index >= SWITCH_MAX_STATE_HANDLERS || index > channel->state_handler_index) {
switch_mutex_unlock(channel->state_mutex);

return NULL;
}

switch_mutex_lock(channel->state_mutex);
h = channel->state_handlers[index];
switch_mutex_unlock(channel->state_mutex);

Expand Down

0 comments on commit 4ff9d35

Please sign in to comment.