aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/conversation.c37
-rw-r--r--epan/packet.c8
2 files changed, 37 insertions, 8 deletions
diff --git a/epan/conversation.c b/epan/conversation.c
index 2b2d4b198a..d40ee7677d 100644
--- a/epan/conversation.c
+++ b/epan/conversation.c
@@ -409,21 +409,48 @@ conversation_match_no_addr2_or_port2(gconstpointer v, gconstpointer w)
}
/*
+ * Free the proto_data. The conversation itself is se_allocated.
+ */
+void
+free_data_list(gpointer key _U_, gpointer value, gpointer user_data _U_)
+{
+ conversation_t *conv = value;
+
+ /* TODO: se_slist? */
+ g_slist_free(conv->data_list);
+
+ /* Not really necessary, but... */
+ conv->data_list = NULL;
+
+}
+
+/*
* Destroy all existing conversations
*/
void
conversation_cleanup(void)
{
- /* The conversation keys are se_ allocated so they are already gone */
+ /* Clean up the hash tables, but only after freeing any proto_data
+ * that may be hanging off the conversations.
+ * The conversation keys are se_ allocated so we don't have to clean them up.
+ */
conversation_keys = NULL;
- if (conversation_hashtable_exact != NULL)
+ if (conversation_hashtable_exact != NULL) {
+ g_hash_table_foreach(conversation_hashtable_exact, free_data_list, NULL);
g_hash_table_destroy(conversation_hashtable_exact);
- if (conversation_hashtable_no_addr2 != NULL)
+ }
+ if (conversation_hashtable_no_addr2 != NULL) {
+ g_hash_table_foreach(conversation_hashtable_no_addr2, free_data_list, NULL);
g_hash_table_destroy(conversation_hashtable_no_addr2);
- if (conversation_hashtable_no_port2 != NULL)
+ }
+ if (conversation_hashtable_no_port2 != NULL) {
+ g_hash_table_foreach(conversation_hashtable_no_port2, free_data_list, NULL);
g_hash_table_destroy(conversation_hashtable_no_port2);
- if (conversation_hashtable_no_addr2_or_port2 != NULL)
+ }
+ if (conversation_hashtable_no_addr2_or_port2 != NULL) {
+ g_hash_table_foreach(conversation_hashtable_no_addr2_or_port2, free_data_list, NULL);
g_hash_table_destroy(conversation_hashtable_no_addr2_or_port2);
+ }
conversation_hashtable_exact = NULL;
conversation_hashtable_no_addr2 = NULL;
diff --git a/epan/packet.c b/epan/packet.c
index 423665c361..b569ff1ec7 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -149,12 +149,14 @@ init_dissection(void)
void
cleanup_dissection(void)
{
+ /* Cleanup the table of conversations. Do this before freeing seasonal
+ * memory (at least until conversation's use of g_slist is changed).
+ */
+ epan_conversation_cleanup();
+
/* Reclaim all memory of seasonal scope */
se_free_all();
- /* Cleanup the table of conversations. */
- epan_conversation_cleanup();
-
/* Cleanup the table of circuits. */
epan_circuit_cleanup();