summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-30 01:11:10 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-07-03 23:54:45 +0200
commit1948fe69bd7d3dba547c1708653ec4fbc08655ac (patch)
tree220139bf21a43bb8a42fdac2f2e3507f9022fcd6
parent57a150f307dbe0469ce3468ca6d4784d0e3f955c (diff)
downloadwireshark-cleanup_routine.tar.gz
plugins: add cleanup routinescleanup_routine
Destroy the reassembly tables on exit, fix memleak in profinet dissector. Change-Id: Id34dbfde42fe715513997452f87cd4fdc328e294
-rw-r--r--plugins/m2m/packet-m2m.c7
-rw-r--r--plugins/opcua/opcua.c7
-rw-r--r--plugins/profinet/packet-dcerpc-pn-io.c7
-rw-r--r--plugins/profinet/packet-dcom-cba.c5
-rw-r--r--plugins/profinet/packet-pn-rt.c20
-rw-r--r--plugins/wimax/mac_hd_generic_decoder.c20
6 files changed, 40 insertions, 26 deletions
diff --git a/plugins/m2m/packet-m2m.c b/plugins/m2m/packet-m2m.c
index 9e0a07aa2d..80bea305b4 100644
--- a/plugins/m2m/packet-m2m.c
+++ b/plugins/m2m/packet-m2m.c
@@ -163,6 +163,12 @@ m2m_defragment_init(void)
&addresses_reassembly_table_functions);
}
+static void
+m2m_defragment_cleanup(void)
+{
+ reassembly_table_destroy(&pdu_reassembly_table);
+}
+
/* WiMax MAC to MAC protocol dissector */
static void dissect_m2m(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -794,6 +800,7 @@ void proto_register_m2m(void)
/* Register the PDU fragment table init routine */
register_init_routine(m2m_defragment_init);
+ register_cleanup_routine(m2m_defragment_cleanup);
}
/* Register Wimax Mac to Mac Protocol handler */
diff --git a/plugins/opcua/opcua.c b/plugins/opcua/opcua.c
index acde1ab74b..9f1bd07f44 100644
--- a/plugins/opcua/opcua.c
+++ b/plugins/opcua/opcua.c
@@ -385,6 +385,12 @@ init_opcua(void)
&addresses_reassembly_table_functions);
}
+static void
+cleanup_opcua(void)
+{
+ reassembly_table_destroy(&opcua_reassembly_table);
+}
+
/** plugin entry functions.
* This registers the OpcUa protocol.
*/
@@ -443,6 +449,7 @@ void proto_register_opcua(void)
proto_register_field_array(proto_opcua, hf, array_length(hf));
register_init_routine(&init_opcua);
+ register_cleanup_routine(&cleanup_opcua);
/* register user preferences */
opcua_module = prefs_register_protocol(proto_opcua, proto_reg_handoff_opcua);
diff --git a/plugins/profinet/packet-dcerpc-pn-io.c b/plugins/profinet/packet-dcerpc-pn-io.c
index c4579c9709..aac79965b5 100644
--- a/plugins/profinet/packet-dcerpc-pn-io.c
+++ b/plugins/profinet/packet-dcerpc-pn-io.c
@@ -2642,7 +2642,7 @@ dissect_profidrive_value(tvbuff_t *tvb, gint offset, packet_info *pinfo,
return(offset);
}
-GList *pnio_ars;
+static GList *pnio_ars;
typedef struct pnio_ar_s {
/* generic */
@@ -9759,7 +9759,8 @@ static dcerpc_sub_dissector pn_io_dissectors[] = {
static void
-pnio_reinit( void) {
+pnio_cleanup(void) {
+ g_list_free(pnio_ars);
pnio_ars = NULL;
}
@@ -12251,7 +12252,7 @@ proto_register_pn_io (void)
new_register_dissector("pn_io", dissect_PNIO_heur, proto_pn_io);
heur_pn_subdissector_list = register_heur_dissector_list("pn_io");
- register_init_routine(pnio_reinit);
+ register_cleanup_routine(pnio_cleanup);
register_dissector_filter("PN-IO AR", pn_io_ar_conv_valid, pn_io_ar_conv_filter);
register_dissector_filter("PN-IO AR (with data)", pn_io_ar_conv_valid, pn_io_ar_conv_data_filter);
diff --git a/plugins/profinet/packet-dcom-cba.c b/plugins/profinet/packet-dcom-cba.c
index b89e9fcfac..244b102cb0 100644
--- a/plugins/profinet/packet-dcom-cba.c
+++ b/plugins/profinet/packet-dcom-cba.c
@@ -1366,7 +1366,8 @@ static dcerpc_sub_dissector ICBASystemProperties_dissectors[] = {
};
-static void cba_reinit( void) {
+static void cba_cleanup(void) {
+ g_list_free(cba_pdevs);
cba_pdevs = NULL;
}
@@ -1642,7 +1643,7 @@ proto_register_dcom_cba (void)
proto_ICBASystemProperties = proto_register_protocol ("ICBASystemProperties", "ICBASysProp", "cba_sysprop");
- register_init_routine(cba_reinit);
+ register_cleanup_routine(cba_cleanup);
}
diff --git a/plugins/profinet/packet-pn-rt.c b/plugins/profinet/packet-pn-rt.c
index 3c43197a6a..cfbfcd3ab2 100644
--- a/plugins/profinet/packet-pn-rt.c
+++ b/plugins/profinet/packet-pn-rt.c
@@ -342,21 +342,18 @@ static void
pnio_defragment_init(void)
{
guint32 i;
-
- if ( reasembled_frag_table != NULL ) {
- g_hash_table_destroy( reasembled_frag_table );
- reasembled_frag_table = NULL;
- }
-
for (i=0; i < 16; i++) /* init the reasemble help array */
start_frag_OR_ID[i] = 0;
-
reassembly_table_init(&pdu_reassembly_table,
&addresses_reassembly_table_functions);
- if (reasembled_frag_table == NULL)
- {
- reasembled_frag_table = g_hash_table_new(NULL, NULL);
- }
+ reasembled_frag_table = g_hash_table_new(NULL, NULL);
+}
+
+static void
+pnio_defragment_cleanup(void)
+{
+ g_hash_table_destroy(reasembled_frag_table);
+ reassembly_table_destroy(&pdu_reassembly_table);
}
/* possibly dissect a FRAG_PDU related PN-RT packet */
@@ -988,6 +985,7 @@ proto_register_pn_rt(void)
init_pn (proto_pn_rt);
register_init_routine(pnio_defragment_init);
+ register_cleanup_routine(pnio_defragment_cleanup);
}
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