From 8fbc0db7d2cc4c040d9cba7623a463e093a9ce5a Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 7 Jul 2014 23:55:54 +0200 Subject: [PATCH] conversion: do not free conversation memory on updates In commit 4afd70d ("Use g_hash_table_new_full to free some values"), the hashtable gained a destroy handler which frees memory. This inadvertently destroyed a conversation during key updates. Fix this by not calling _remove (and thereby calling the destroy handler), but use _steal instead. (Suggestion by Evan Huus). Bug: 10263 Change-Id: I9fa7f5a697599f42894d38718b00b9c0c1b57004 Reviewed-on: https://code.wireshark.org/review/2924 Reviewed-by: Peter Wu Reviewed-by: Evan Huus --- epan/conversation.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/epan/conversation.c b/epan/conversation.c index 44666b3656..b68da789ea 100644 --- a/epan/conversation.c +++ b/epan/conversation.c @@ -609,8 +609,12 @@ conversation_remove_from_hashtable(GHashTable *hashtable, conversation_t *conv) if (conv == chain_head) { /* We are currently the front of the chain */ if (NULL == conv->next) { - /* We are the only conversation in the chain */ - g_hash_table_remove(hashtable, conv->key_ptr); + /* We are the only conversation in the chain, no need to + * update next pointer, but do not call + * g_hash_table_remove() either because the conv data + * will be re-inserted. The memory is released when + * conversion_cleanup() is called. */ + g_hash_table_steal(hashtable, conv->key_ptr); } else { /* Update the head of the chain */