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 <peter@lekensteyn.nl>
Reviewed-by: Evan Huus <eapache@gmail.com>
This commit is contained in:
Peter Wu 2014-07-07 23:55:54 +02:00 committed by Evan Huus
parent 9b4f16a204
commit 8fbc0db7d2
1 changed files with 6 additions and 2 deletions

View File

@ -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 */