From 0914a501cd315fc2b397cf7dd4a296e36eb7a051 Mon Sep 17 00:00:00 2001 From: Tamas Cseke Date: Wed, 24 Feb 2016 14:20:56 +0100 Subject: [PATCH] Fix memory leaks Destroy session event hash and events in queue FS-8866 --resolve --- .../event_handlers/mod_erlang_event/mod_erlang_event.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index f3e8e7cd87..2196cadfc7 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -382,6 +382,7 @@ static void remove_session_elem_from_listener(listener_t *listener, session_elem static void destroy_session_elem(session_elem_t *session_element) { switch_core_session_t *session; + void *pop; /* wait for readers */ switch_thread_rwlock_wrlock(session_element->rwlock); @@ -395,6 +396,13 @@ static void destroy_session_elem(session_elem_t *session_element) switch_core_session_soft_unlock(session); switch_core_session_rwunlock(session); } + + while (switch_queue_trypop(session_element->event_queue, &pop) == SWITCH_STATUS_SUCCESS) { + switch_event_t *event = (switch_event_t *) pop; + switch_event_destroy(&event); + } + + switch_core_hash_destroy(&session_element->event_hash); switch_core_destroy_memory_pool(&session_element->pool); }