From 7b33634cc562ba0ee75536b7dde4268a20d89bee Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 30 Jun 2015 01:11:10 +0200 Subject: plugins: add cleanup routines Destroy the reassembly tables on exit, fix memleak in profinet dissector. Change-Id: Id34dbfde42fe715513997452f87cd4fdc328e294 Reviewed-on: https://code.wireshark.org/review/9229 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- plugins/wimax/mac_hd_generic_decoder.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'plugins/wimax') diff --git a/plugins/wimax/mac_hd_generic_decoder.c b/plugins/wimax/mac_hd_generic_decoder.c index e919e052a5..ae0cdbba77 100644 --- a/plugins/wimax/mac_hd_generic_decoder.c +++ b/plugins/wimax/mac_hd_generic_decoder.c @@ -610,16 +610,6 @@ static void wimax_defragment_init(void) cid_vernier[i] = 0; } cid_adj_array_size = 0; - /* Free the array memory. */ - if (cid_adj_array) { - g_free(cid_adj_array); - } - cid_adj_array = NULL; - if (frag_num_array) { - g_free(frag_num_array); - } - frag_num_array = NULL; - /* Initialize to make sure bs_address gets set in FCH decoder. */ bs_address.len = 0; @@ -632,6 +622,15 @@ static void wimax_defragment_init(void) init_wimax_globals(); } +static void wimax_defragment_cleanup(void) +{ + reassembly_table_destroy(&payload_reassembly_table); + g_free(cid_adj_array); + cid_adj_array = NULL; + g_free(frag_num_array); + frag_num_array = NULL; +} + static guint decode_packing_subheader(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree *tree, guint payload_length _U_, guint payload_offset, proto_item *parent_item) { proto_item *generic_item = NULL; @@ -2271,6 +2270,7 @@ void proto_register_mac_header_generic(void) /* Register the payload fragment table init routine */ register_init_routine(wimax_defragment_init); + register_cleanup_routine(wimax_defragment_cleanup); } void -- cgit v1.2.1