From 9030e13589bb69546bf5c3460471191246533016 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 3 Aug 2016 18:41:18 -0500 Subject: [PATCH] FS-9401: [core,mod_amqp] fix leak in usage of hash itterator --- src/mod/event_handlers/mod_amqp/mod_amqp_logging.c | 5 +++-- src/switch_event.c | 1 + src/switch_jitterbuffer.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mod/event_handlers/mod_amqp/mod_amqp_logging.c b/src/mod/event_handlers/mod_amqp/mod_amqp_logging.c index 8d4e4805be..da512cef39 100644 --- a/src/mod/event_handlers/mod_amqp/mod_amqp_logging.c +++ b/src/mod/event_handlers/mod_amqp/mod_amqp_logging.c @@ -94,12 +94,13 @@ switch_status_t mod_amqp_logging_recv(const switch_log_node_t *node, switch_log_ if (switch_queue_trypush(logging->send_queue, msg) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AMQP logging message queue full. Messages will be dropped!\n"); - return SWITCH_STATUS_SUCCESS; + switch_safe_free(hi); + goto done; } } } - + done: switch_safe_free(json); return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_event.c b/src/switch_event.c index 58d5b81735..4ebe0f37d5 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -2752,6 +2752,7 @@ static void unsub_all_switch_event_channel(void) free(head); } + switch_safe_free(hi); switch_thread_rwlock_unlock(event_channel_manager.rwlock); } diff --git a/src/switch_jitterbuffer.c b/src/switch_jitterbuffer.c index 427498a5d2..b396dd4611 100644 --- a/src/switch_jitterbuffer.c +++ b/src/switch_jitterbuffer.c @@ -1039,7 +1039,7 @@ SWITCH_DECLARE(uint32_t) switch_jb_pop_nack(switch_jb_t *jb) top: - for (hi = switch_core_hash_first(jb->missing_seq_hash); hi; hi = switch_core_hash_next(&hi)) { + for (hi = switch_core_hash_first_iter(jb->missing_seq_hash, hi); hi; hi = switch_core_hash_next(&hi)) { uint16_t seq; //const char *token; switch_time_t then = 0; @@ -1076,6 +1076,8 @@ SWITCH_DECLARE(uint32_t) switch_jb_pop_nack(switch_jb_t *jb) } } + switch_safe_free(hi); + if (least && switch_core_inthash_delete(jb->missing_seq_hash, (uint32_t)htons(least))) { jb_debug(jb, 3, "Found NACKABLE seq %u\n", least); nack = (uint32_t) htons(least);