]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9401: [core,mod_amqp] fix leak in usage of hash itterator
authorMichael Jerris <mike@jerris.com>
Wed, 3 Aug 2016 23:41:18 +0000 (18:41 -0500)
committerMichael Jerris <mike@jerris.com>
Wed, 3 Aug 2016 23:41:18 +0000 (18:41 -0500)
src/mod/event_handlers/mod_amqp/mod_amqp_logging.c
src/switch_event.c
src/switch_jitterbuffer.c

index 8d4e4805be3d9a17479fb681baeb3322dc8094cb..da512cef39e4a0949d0b8c555e8c334395324bf4 100644 (file)
@@ -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;
 }
index 58d5b81735adfd2d4d5e8b50c564b275046d4879..4ebe0f37d52e5834841d44e33107d3e64c62ab12 100644 (file)
@@ -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);
 }
 
index 427498a5d2d435265b899a99852a3bb53abdc4e2..b396dd4611b8c9383ac92684d7ad5d02f1446391 100644 (file)
@@ -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);