aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-08-28 12:40:38 +0100
committerMichael Mann <mmann78@netscape.net>2017-08-28 23:49:40 +0000
commita303bc1f2982e59885c9787d3f81e1ced4b5f342 (patch)
treee5618f88c6603738ca406e69954a5fe8a2400bba /plugins
parent6cd7d99cb98c17c593948753d2a3b2a65d4f6040 (diff)
transum: clear the list of wanted hfids in file cleanup routine
Be sure to disable the wanted hfids list when the transum dissector is cleaned up, otherwise it will leak memory when reloading a file while the transum dissector is enabled. Change-Id: I2af8edab89da8b3cfb65e19726e1d2546a1dc8d4 Reviewed-on: https://code.wireshark.org/review/23261 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/transum/packet-transum.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/transum/packet-transum.c b/plugins/transum/packet-transum.c
index aa1db0f..c70028b 100644
--- a/plugins/transum/packet-transum.c
+++ b/plugins/transum/packet-transum.c
@@ -141,11 +141,6 @@ static wmem_map_t *output_rrpd;
*/
static wmem_list_t *temp_rsp_rrpd_list = NULL; /* Reuse these for speed and efficient memory use - issue a warning if we run out */
-/*
- * GArray of the hfids of all fields we're interested in.
- */
-GArray *wanted_fields;
-
static gint ett_transum = -1;
static gint ett_transum_header = -1;
static gint ett_transum_data = -1;
@@ -707,7 +702,7 @@ static void init_globals(void)
temp_rsp_rrpd_list = wmem_list_new(wmem_file_scope());
/* Indicate what fields we're interested in. */
- wanted_fields = g_array_new(FALSE, FALSE, (guint)sizeof(int));
+ GArray *wanted_fields = g_array_sized_new(FALSE, FALSE, (guint)sizeof(int), HF_INTEREST_END_OF_LIST);
for (int i = 0; i < HF_INTEREST_END_OF_LIST; i++)
{
g_array_append_val(wanted_fields, hf_of_interest[i].hf);
@@ -746,6 +741,13 @@ static void init_globals(void)
output_rrpd = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
}
+/* Undo capture file-specific initializations. */
+static void cleanup_globals(void)
+{
+ /* Clear the list of wanted fields as it will be reinitialized. */
+ set_postdissector_wanted_hfids(transum_handle, NULL);
+}
+
/* This function adds the RTE data to the tree. The summary ptr is currently
not used but will be used for summariser information once this feature has
been ported from the LUA code. */
@@ -1195,6 +1197,7 @@ proto_register_transum(void)
transum_handle = register_dissector("transum", dissect_transum, proto_transum);
register_init_routine(init_globals);
+ register_cleanup_routine(cleanup_globals);
register_postdissector(transum_handle);
}