diff options
36 files changed, 257 insertions, 199 deletions
diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c index 1add0ed3a5..1e6a521cfb 100644 --- a/epan/dissectors/packet-afp.c +++ b/epan/dissectors/packet-afp.c @@ -5527,14 +5527,14 @@ dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) return tvb_captured_length(tvb); } -static void afp_reinit( void) +static void afp_init(void) { - - if (afp_request_hash) - g_hash_table_destroy(afp_request_hash); - afp_request_hash = g_hash_table_new(afp_hash, afp_equal); +} +static void afp_cleanup(void) +{ + g_hash_table_destroy(afp_request_hash); } void @@ -7263,7 +7263,8 @@ proto_register_afp(void) expert_afp = expert_register_protocol(proto_afp); expert_register_field_array(expert_afp, ei, array_length(ei)); - register_init_routine(afp_reinit); + register_init_routine(afp_init); + register_cleanup_routine(afp_cleanup); new_register_dissector("afp", dissect_afp, proto_afp); new_register_dissector("afp_server_status", dissect_afp_server_status, diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c index 9613533774..1e9a5dac12 100644 --- a/epan/dissectors/packet-afs.c +++ b/epan/dissectors/packet-afs.c @@ -1415,17 +1415,18 @@ afs_hash (gconstpointer v) static void afs_init_protocol(void) { - if (afs_request_hash) - g_hash_table_destroy(afs_request_hash); - afs_request_hash = g_hash_table_new(afs_hash, afs_equal); - - /* fragment_table_init(&afs_fragment_table); */ - /* reassembled_table_init(&afs_reassembled_table); */ reassembly_table_init(&afs_reassembly_table, &addresses_reassembly_table_functions); } +static void +afs_cleanup_protocol(void) +{ + reassembly_table_destroy(&afs_reassembly_table); + g_hash_table_destroy(afs_request_hash); +} + /* * Here is a helper routine for adding an AFS acl to the proto tree * This is to be used with FS packets only @@ -3631,6 +3632,7 @@ proto_register_afs(void) proto_register_field_array(proto_afs, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); register_init_routine(&afs_init_protocol); + register_cleanup_routine(&afs_cleanup_protocol); new_register_dissector("afs", dissect_afs, proto_afs); } diff --git a/epan/dissectors/packet-aoe.c b/epan/dissectors/packet-aoe.c index df51b47bf0..5369bfc50f 100644 --- a/epan/dissectors/packet-aoe.c +++ b/epan/dissectors/packet-aoe.c @@ -392,18 +392,15 @@ dissect_aoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) static void ata_init(void) { - if(ata_cmd_unmatched){ - g_hash_table_destroy(ata_cmd_unmatched); - ata_cmd_unmatched=NULL; - } ata_cmd_unmatched=g_hash_table_new(ata_cmd_hash_unmatched, ata_cmd_equal_unmatched); - - if(ata_cmd_matched){ - g_hash_table_destroy(ata_cmd_matched); - ata_cmd_matched=NULL; - } ata_cmd_matched=g_hash_table_new(ata_cmd_hash_matched, ata_cmd_equal_matched); +} +static void +ata_cleanup(void) +{ + g_hash_table_destroy(ata_cmd_unmatched); + g_hash_table_destroy(ata_cmd_matched); } void @@ -475,6 +472,7 @@ proto_register_aoe(void) aoe_handle = register_dissector("aoe", dissect_aoe, proto_aoe); register_init_routine(ata_init); + register_cleanup_routine(ata_cleanup); } void diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c index b944c5778e..ad044be785 100644 --- a/epan/dissectors/packet-arp.c +++ b/epan/dissectors/packet-arp.c @@ -744,21 +744,18 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree, static void arp_init_protocol(void) { - /* Destroy any existing hashes. */ - if (address_hash_table) { - g_hash_table_destroy(address_hash_table); - } - if (duplicate_result_hash_table) { - g_hash_table_destroy(duplicate_result_hash_table); - } - - - /* Now create it over */ address_hash_table = g_hash_table_new(address_hash_func, address_equal_func); duplicate_result_hash_table = g_hash_table_new(duplicate_result_hash_func, duplicate_result_equal_func); } +static void +arp_cleanup_protocol(void) +{ + g_hash_table_destroy(address_hash_table); + g_hash_table_destroy(duplicate_result_hash_table); +} + @@ -2000,6 +1997,7 @@ proto_register_arp(void) /* TODO: define a minimum time between sightings that is worth reporting? */ register_init_routine(&arp_init_protocol); + register_cleanup_routine(&arp_cleanup_protocol); } void diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c index 4beecae7ff..85300f7128 100644 --- a/epan/dissectors/packet-atalk.c +++ b/epan/dissectors/packet-atalk.c @@ -1618,15 +1618,16 @@ dissect_llap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) static void atp_init(void) { - /* fragment */ reassembly_table_init(&atp_reassembly_table, &addresses_reassembly_table_functions); - /* bitmap */ - if (atp_request_hash) - g_hash_table_destroy(atp_request_hash); - atp_request_hash = g_hash_table_new(asp_hash, asp_equal); +} +static void +atp_cleanup(void) +{ + reassembly_table_destroy(&atp_reassembly_table); + g_hash_table_destroy(atp_request_hash); } static void @@ -2110,6 +2111,7 @@ proto_reg_handoff_atalk(void) dissector_add_uint("wtap_encap", WTAP_ENCAP_LOCALTALK, llap_handle); register_init_routine( atp_init); + register_cleanup_routine( atp_cleanup); register_init_routine( &asp_reinit); afp_handle = find_dissector("afp"); diff --git a/epan/dissectors/packet-dcerpc-netlogon.c b/epan/dissectors/packet-dcerpc-netlogon.c index 2e5f0e7775..e1e835926c 100644 --- a/epan/dissectors/packet-dcerpc-netlogon.c +++ b/epan/dissectors/packet-dcerpc-netlogon.c @@ -7845,15 +7845,15 @@ static const value_string sec_chan_type_vals[] = { static void netlogon_reassemble_init(void) { - if (netlogon_auths){ - g_hash_table_destroy (netlogon_auths); - } netlogon_auths = g_hash_table_new (netlogon_auth_hash, netlogon_auth_equal); - if (schannel_auths){ - g_hash_table_destroy (schannel_auths); - } schannel_auths = g_hash_table_new (netlogon_auth_hash, netlogon_auth_equal); +} +static void +netlogon_reassemble_cleanup(void) +{ + g_hash_table_destroy(netlogon_auths); + g_hash_table_destroy(schannel_auths); } void @@ -9265,6 +9265,7 @@ proto_register_dcerpc_netlogon(void) array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); register_init_routine(netlogon_reassemble_init); + register_cleanup_routine(netlogon_reassemble_cleanup); } diff --git a/epan/dissectors/packet-dcerpc-nt.c b/epan/dissectors/packet-dcerpc-nt.c index 2f463288e8..5a6b6a4087 100644 --- a/epan/dissectors/packet-dcerpc-nt.c +++ b/epan/dissectors/packet-dcerpc-nt.c @@ -870,18 +870,14 @@ gboolean dcerpc_fetch_polhnd_data(e_ctx_hnd *policy_hnd, static void init_pol_hash(void) { - /* Initialise hash table */ - - if (pol_hash) { - /* Everything in the table is allocated with wmem file - * scope so there's no need to go through and free it all. - */ - g_hash_table_destroy(pol_hash); - } - pol_hash = g_hash_table_new(pol_hash_fn, pol_hash_compare); } +static void cleanup_pol_hash(void) +{ + g_hash_table_destroy(pol_hash); +} + /* Dissect a NT status code */ int @@ -2025,6 +2021,7 @@ void dcerpc_smb_init(int proto_dcerpc) expert_dcerpc_nt = expert_register_protocol(proto_dcerpc); expert_register_field_array(expert_dcerpc_nt, ei, array_length(ei)); register_init_routine(&init_pol_hash); + register_cleanup_routine(&cleanup_pol_hash); } /* diff --git a/epan/dissectors/packet-dmp.c b/epan/dissectors/packet-dmp.c index be150ce3f1..919bad8f13 100644 --- a/epan/dissectors/packet-dmp.c +++ b/epan/dissectors/packet-dmp.c @@ -4087,17 +4087,16 @@ static int dissect_dmp (tvbuff_t *tvb, packet_info *pinfo, static void dmp_init_routine (void) { - if (dmp_id_hash_table) { - g_hash_table_destroy (dmp_id_hash_table); - } - if (dmp_long_id_hash_table) { - g_hash_table_destroy (dmp_long_id_hash_table); - } - dmp_id_hash_table = g_hash_table_new (dmp_id_hash, dmp_id_hash_equal); dmp_long_id_hash_table = g_hash_table_new (g_str_hash, g_str_equal); } +static void dmp_cleanup_routine (void) +{ + g_hash_table_destroy(dmp_id_hash_table); + g_hash_table_destroy(dmp_long_id_hash_table); +} + void proto_register_dmp (void) { static hf_register_info hf[] = { @@ -4989,6 +4988,7 @@ void proto_register_dmp (void) expert_dmp = expert_register_protocol(proto_dmp); expert_register_field_array(expert_dmp, ei, array_length(ei)); register_init_routine (&dmp_init_routine); + register_cleanup_routine (&dmp_cleanup_routine); /* Set default UDP ports */ range_convert_str (&global_dmp_port_range, DEFAULT_DMP_PORT_RANGE, diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index 9653356e8f..f767f7f9aa 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -3521,16 +3521,18 @@ dissect_dnp3_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data static void dnp3_init(void) { - if (dl_conversation_table) - { - g_hash_table_destroy(dl_conversation_table); - } dl_conversation_table = g_hash_table_new(dl_conversation_hash, dl_conversation_equal); - reassembly_table_init(&al_reassembly_table, &addresses_reassembly_table_functions); } +static void +dnp3_cleanup(void) +{ + reassembly_table_destroy(&al_reassembly_table); + g_hash_table_destroy(dl_conversation_table); +} + /* Register the protocol with Wireshark */ void @@ -4526,6 +4528,7 @@ proto_register_dnp3(void) /* Register protocol init routine */ register_init_routine(&dnp3_init); + register_cleanup_routine(&dnp3_cleanup); /* Register the protocol name and description */ proto_dnp3 = proto_register_protocol("Distributed Network Protocol 3.0", diff --git a/epan/dissectors/packet-dvbci.c b/epan/dissectors/packet-dvbci.c index 83bd1343c1..4a98d4c77b 100644 --- a/epan/dissectors/packet-dvbci.c +++ b/epan/dissectors/packet-dvbci.c @@ -1700,13 +1700,19 @@ dvbci_init(void) { buf_size_cam = 0; buf_size_host = 0; - reassembly_table_init(&tpdu_reassembly_table, &addresses_reassembly_table_functions); reassembly_table_init(&spdu_reassembly_table, &addresses_reassembly_table_functions); } +static void +dvbci_cleanup(void) +{ + reassembly_table_destroy(&tpdu_reassembly_table); + reassembly_table_destroy(&spdu_reassembly_table); +} + /* dissect a delivery system descriptor loop and the preceding length field @@ -6328,6 +6334,7 @@ proto_register_dvbci(void) "SAS application id", FT_STRING, STR_ASCII); register_init_routine(dvbci_init); + register_cleanup_routine(dvbci_cleanup); /* the dissector for decrypted CI+ SAC messages which we can export */ new_register_dissector(EXPORTED_SAC_MSG_PROTO, diff --git a/epan/dissectors/packet-enip.c b/epan/dissectors/packet-enip.c index 398aa52ca0..87cae5b744 100644 --- a/epan/dissectors/packet-enip.c +++ b/epan/dissectors/packet-enip.c @@ -1753,15 +1753,17 @@ attribute_info_t enip_attribute_vals[45] = { static void enip_init_protocol(void) { - if (enip_request_hashtable) - g_hash_table_destroy(enip_request_hashtable); enip_request_hashtable = g_hash_table_new(enip_request_hash, enip_request_equal); - - if (enip_conn_hashtable) - g_hash_table_destroy(enip_conn_hashtable); enip_conn_hashtable = g_hash_table_new(enip_conn_hash, enip_conn_equal); } +static void +enip_cleanup_protocol(void) +{ + g_hash_table_destroy(enip_request_hashtable); + g_hash_table_destroy(enip_conn_hashtable); +} + /* Disssect Common Packet Format */ static void dissect_cpf(enip_request_key_t *request_key, int command, tvbuff_t *tvb, @@ -3726,6 +3728,7 @@ proto_register_enip(void) subdissector_io_table = register_dissector_table("enip.io", "ENIP IO dissector", FT_UINT32, BASE_DEC); register_init_routine(&enip_init_protocol); + register_cleanup_routine(&enip_cleanup_protocol); /* Register the protocol name and description */ proto_dlr = proto_register_protocol("Device Level Ring", "DLR", "dlr"); diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index 0846dc50bc..5b06e7793e 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -195,13 +195,16 @@ fc_exchange_init_protocol(void) { reassembly_table_init(&fc_reassembly_table, &addresses_reassembly_table_functions); - - if (fcseq_req_hash) - g_hash_table_destroy(fcseq_req_hash); - fcseq_req_hash = g_hash_table_new(fcseq_hash, fcseq_equal); } +static void +fc_exchange_cleanup_protocol(void) +{ + reassembly_table_destroy(&fc_reassembly_table); + g_hash_table_destroy(fcseq_req_hash); +} + static const char* fc_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter) { if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_FC)) @@ -1575,6 +1578,7 @@ proto_register_fc(void) &fc_max_frame_size); register_init_routine (fc_exchange_init_protocol); + register_cleanup_routine (fc_exchange_cleanup_protocol); /* Register FC SOF/EOF */ diff --git a/epan/dissectors/packet-fcdns.c b/epan/dissectors/packet-fcdns.c index 8a9df627c2..61c02d749a 100644 --- a/epan/dissectors/packet-fcdns.c +++ b/epan/dissectors/packet-fcdns.c @@ -383,12 +383,15 @@ fcdns_hash (gconstpointer v) static void fcdns_init_protocol(void) { - if (fcdns_req_hash) - g_hash_table_destroy(fcdns_req_hash); - fcdns_req_hash = g_hash_table_new(fcdns_hash, fcdns_equal); } +static void +fcdns_cleanup_protocol(void) +{ + g_hash_table_destroy(fcdns_req_hash); +} + static void dissect_cos_flags (proto_tree *parent_tree, tvbuff_t *tvb, int offset, const header_field_info *hfinfo) @@ -1854,6 +1857,7 @@ proto_register_fcdns (void) expert_fcdns = expert_register_protocol(proto_fcdns); expert_register_field_array(expert_fcdns, ei, array_length(ei)); register_init_routine (&fcdns_init_protocol); + register_cleanup_routine (&fcdns_cleanup_protocol); dns_handle = new_create_dissector_handle (dissect_fcdns, proto_fcdns); } diff --git a/epan/dissectors/packet-fcels.c b/epan/dissectors/packet-fcels.c index d38c3c2074..30e3934aee 100644 --- a/epan/dissectors/packet-fcels.c +++ b/epan/dissectors/packet-fcels.c @@ -652,12 +652,15 @@ fcels_hash (gconstpointer v) static void fcels_init_protocol(void) { - if (fcels_req_hash) - g_hash_table_destroy(fcels_req_hash); - fcels_req_hash = g_hash_table_new(fcels_hash, fcels_equal); } +static void +fcels_cleanup_protocol(void) +{ + g_hash_table_destroy(fcels_req_hash); +} + static const true_false_string tfs_fc_fcels_cmn_b2b = { "Alt B2B Credit Mgmt", "Normal B2B Credit Mgmt" @@ -2613,6 +2616,7 @@ proto_register_fcels (void) expert_fcels = expert_register_protocol(proto_fcels); expert_register_field_array(expert_fcels, ei, array_length(ei)); register_init_routine (&fcels_init_protocol); + register_cleanup_routine (&fcels_cleanup_protocol); } void diff --git a/epan/dissectors/packet-fcfcs.c b/epan/dissectors/packet-fcfcs.c index 07ebd84089..ee93ca0ef2 100644 --- a/epan/dissectors/packet-fcfcs.c +++ b/epan/dissectors/packet-fcfcs.c @@ -130,12 +130,15 @@ fcfcs_hash (gconstpointer v) static void fcfcs_init_protocol(void) { - if (fcfcs_req_hash) - g_hash_table_destroy (fcfcs_req_hash); - fcfcs_req_hash = g_hash_table_new(fcfcs_hash, fcfcs_equal); } +static void +fcfcs_cleanup_protocol(void) +{ + g_hash_table_destroy(fcfcs_req_hash); +} + /* Code to actually dissect the packets */ static void dissect_fcfcs_giel (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) @@ -1042,6 +1045,7 @@ proto_register_fcfcs (void) expert_register_field_array(expert_fcfcs, ei, array_length(ei)); register_init_routine (&fcfcs_init_protocol); + register_cleanup_routine (&fcfcs_cleanup_protocol); } void diff --git a/epan/dissectors/packet-fcfzs.c b/epan/dissectors/packet-fcfzs.c index 56e5bb96e5..d0a72f64e1 100644 --- a/epan/dissectors/packet-fcfzs.c +++ b/epan/dissectors/packet-fcfzs.c @@ -114,12 +114,15 @@ fcfzs_hash(gconstpointer v) static void fcfzs_init_protocol(void) { - if (fcfzs_req_hash) - g_hash_table_destroy(fcfzs_req_hash); - fcfzs_req_hash = g_hash_table_new(fcfzs_hash, fcfzs_equal); } +static void +fcfzs_cleanup_protocol(void) +{ + g_hash_table_destroy(fcfzs_req_hash); +} + /* Code to actually dissect the packets */ static void dissect_fcfzs_zoneset(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset) @@ -867,6 +870,7 @@ proto_register_fcfzs(void) expert_fcfzs = expert_register_protocol(proto_fcfzs); expert_register_field_array(expert_fcfzs, ei, array_length(ei)); register_init_routine(&fcfzs_init_protocol); + register_cleanup_routine(&fcfzs_cleanup_protocol); } diff --git a/epan/dissectors/packet-fcswils.c b/epan/dissectors/packet-fcswils.c index 327eba4281..81a11dcd2f 100644 --- a/epan/dissectors/packet-fcswils.c +++ b/epan/dissectors/packet-fcswils.c @@ -486,11 +486,13 @@ fcswils_hash(gconstpointer v) static void fcswils_init_protocol(void) { - if (fcswils_req_hash) - g_hash_table_destroy(fcswils_req_hash); - fcswils_req_hash = g_hash_table_new(fcswils_hash, fcswils_equal); +} +static void +fcswils_cleanup_protocol(void) +{ + g_hash_table_destroy(fcswils_req_hash); } static guint8 * @@ -2531,6 +2533,7 @@ proto_register_fcswils(void) expert_fcswils = expert_register_protocol(proto_fcswils); expert_register_field_array(expert_fcswils, ei, array_length(ei)); register_init_routine(&fcswils_init_protocol); + register_cleanup_routine(&fcswils_cleanup_protocol); } void diff --git a/epan/dissectors/packet-gsm_sms.c b/epan/dissectors/packet-gsm_sms.c index 3b0ab8541f..5c84776d31 100644 --- a/epan/dissectors/packet-gsm_sms.c +++ b/epan/dissectors/packet-gsm_sms.c @@ -334,12 +334,16 @@ gsm_sms_defragment_init (void) { reassembly_table_init(&g_sm_reassembly_table, &addresses_reassembly_table_functions); - if (g_sm_fragment_params_table) { - g_hash_table_destroy(g_sm_fragment_params_table); - } g_sm_fragment_params_table = g_hash_table_new(g_direct_hash, g_direct_equal); } +static void +gsm_sms_defragment_cleanup (void) +{ + reassembly_table_destroy(&g_sm_reassembly_table); + g_hash_table_destroy(g_sm_fragment_params_table); +} + /* * this is the GSM 03.40 definition with the bit 2 * set to 1 for uplink messages @@ -3285,6 +3289,7 @@ proto_register_gsm_sms(void) /* GSM SMS UD dissector initialization routines */ register_init_routine (gsm_sms_defragment_init); + register_cleanup_routine (gsm_sms_defragment_cleanup); } /* diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index f68df30779..83f616010d 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -510,10 +510,8 @@ spx_hash_func(gconstpointer v) static void spx_init_protocol(void) { - - if (spx_hash) - g_hash_table_destroy(spx_hash); - + /* no need for register_cleanup_routine that destroys spx_hash, + * spx_postseq_cleanup should clear this. */ spx_hash = g_hash_table_new(spx_hash_func, spx_equal); } diff --git a/epan/dissectors/packet-iuup.c b/epan/dissectors/packet-iuup.c index 9f8e0b8ce7..72140f3c28 100644 --- a/epan/dissectors/packet-iuup.c +++ b/epan/dissectors/packet-iuup.c @@ -838,11 +838,13 @@ static void find_iuup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { } static void init_iuup(void) { - if (circuits) - g_hash_table_destroy(circuits); circuits = g_hash_table_new(g_direct_hash,g_direct_equal); } +static void cleanup_iuup(void) { + g_hash_table_destroy(circuits); +} + void proto_reg_handoff_iuup(void) { static gboolean iuup_prefs_initialized = FALSE; @@ -1002,6 +1004,7 @@ void proto_register_iuup(void) { register_dissector("find_iuup", find_iuup, proto_iuup); register_init_routine(&init_iuup); + register_cleanup_routine(&cleanup_iuup); iuup_module = prefs_register_protocol(proto_iuup, proto_reg_handoff_iuup); diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c index 21b5fdfdbb..d015d07669 100644 --- a/epan/dissectors/packet-mgcp.c +++ b/epan/dissectors/packet-mgcp.c @@ -670,15 +670,14 @@ static void mgcp_raw_text_add(tvbuff_t *tvb, proto_tree *tree) /* Discard and init any state we've saved */ static void mgcp_init_protocol(void) { - if (mgcp_calls != NULL) - { - g_hash_table_destroy(mgcp_calls); - mgcp_calls = NULL; - } - mgcp_calls = g_hash_table_new(mgcp_call_hash, mgcp_call_equal); } +static void mgcp_cleanup_protocol(void) +{ + g_hash_table_destroy(mgcp_calls); +} + /* * is_mgcp_verb - A function for determining whether there is a @@ -2307,6 +2306,7 @@ void proto_register_mgcp(void) proto_register_field_array(proto_mgcp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); register_init_routine(&mgcp_init_protocol); + register_cleanup_routine(&mgcp_cleanup_protocol); new_register_dissector("mgcp", dissect_mgcp, proto_mgcp); diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index ff3ff346d2..e4384d4655 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -484,18 +484,13 @@ mncp_hash(gconstpointer v) static void mncp_init_protocol(void) { - if (mncp_rhash) - g_hash_table_destroy(mncp_rhash); - mncp_rhash = g_hash_table_new(mncp_hash, mncp_equal); } -/* After the sequential run, we don't need the ncp_request hash and keys - * anymore; the lookups have already been done and the vital info - * saved in the reply-packets' private_data in the frame_data struct. */ static void -mncp_postseq_cleanup(void) +mncp_cleanup_protocol(void) { + g_hash_table_destroy(mncp_rhash); } static mncp_rhash_value* @@ -1381,9 +1376,9 @@ proto_register_ncp(void) "Whether the NCP dissector should echo file open/close/oplock information to the expert table.", &ncp_echo_file); register_init_routine(&mncp_init_protocol); + register_cleanup_routine(&mncp_cleanup_protocol); ncp_tap.stat=register_tap("ncp_srt"); ncp_tap.hdr=register_tap("ncp"); - register_postseq_cleanup_routine(&mncp_postseq_cleanup); register_conversation_table(proto_ncp, FALSE, ncp_conversation_packet, ncp_hostlist_packet); register_srt_table(proto_ncp, "ncp_srt", 24, ncpstat_packet, ncpstat_init, NULL); diff --git a/epan/dissectors/packet-ndps.c b/epan/dissectors/packet-ndps.c index a8565f16cd..0feaaee10b 100644 --- a/epan/dissectors/packet-ndps.c +++ b/epan/dissectors/packet-ndps.c @@ -4079,16 +4079,18 @@ ndps_hash(gconstpointer v) static void ndps_init_protocol(void) { - /* fragment */ reassembly_table_init(&ndps_reassembly_table, &addresses_reassembly_table_functions); - - if (ndps_req_hash) - g_hash_table_destroy(ndps_req_hash); - ndps_req_hash = g_hash_table_new(ndps_hash, ndps_equal); } +static void +ndps_cleanup_protocol(void) +{ + reassembly_table_destroy(&ndps_reassembly_table); + /* ndps_req_hash is already destroyed by ndps_postseq_cleanup */ +} + /* After the sequential run, we don't need the ncp_request hash and keys * anymore; the lookups have already been done and the vital info * saved in the reply-packets' private_data in the frame_data struct. */ @@ -4100,7 +4102,7 @@ ndps_postseq_cleanup(void) g_hash_table_destroy(ndps_req_hash); ndps_req_hash = NULL; } - /* Don't free the ncp_req_hash_values, as they're + /* Don't free the ndps_req_hash_value values of ndps_req_hash, as they're * needed during random-access processing of the proto_tree.*/ } @@ -9513,6 +9515,7 @@ proto_register_ndps(void) &ndps_show_oids); register_init_routine(&ndps_init_protocol); + register_cleanup_routine(&ndps_cleanup_protocol); register_postseq_cleanup_routine(&ndps_postseq_cleanup); } diff --git a/epan/dissectors/packet-netflow.c b/epan/dissectors/packet-netflow.c index 1d07cb5b49..4e444eaf08 100644 --- a/epan/dissectors/packet-netflow.c +++ b/epan/dissectors/packet-netflow.c @@ -7442,23 +7442,19 @@ getprefix(const guint32 *addr, int prefix) static void netflow_init(void) { - /* keys & values are allocated using 'wmem_file_scope()' as thus freed as part of the init sequence */ - if (v9_v10_tmplt_table != NULL) { - g_hash_table_destroy(v9_v10_tmplt_table); - } v9_v10_tmplt_table = g_hash_table_new(v9_v10_tmplt_table_hash, v9_v10_tmplt_table_equal); - - if (netflow_sequence_analysis_domain_hash != NULL) { - g_hash_table_destroy(netflow_sequence_analysis_domain_hash); - } netflow_sequence_analysis_domain_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - - if (netflow_sequence_analysis_result_hash != NULL) { - g_hash_table_destroy(netflow_sequence_analysis_result_hash); - } netflow_sequence_analysis_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); } +static void +netflow_cleanup(void) +{ + g_hash_table_destroy(v9_v10_tmplt_table); + g_hash_table_destroy(netflow_sequence_analysis_domain_hash); + g_hash_table_destroy(netflow_sequence_analysis_result_hash); +} + void proto_register_netflow(void) { @@ -11531,6 +11527,7 @@ proto_register_netflow(void) 10, &v9_tmplt_max_fields); register_init_routine(&netflow_init); + register_cleanup_routine(&netflow_cleanup); } diff --git a/epan/dissectors/packet-ositp.c b/epan/dissectors/packet-ositp.c index 1d2769ba18..1266cb87af 100644 --- a/epan/dissectors/packet-ositp.c +++ b/epan/dissectors/packet-ositp.c @@ -2231,6 +2231,12 @@ cotp_reassemble_init(void) cotp_dst_ref = 0; } +static void +cotp_reassemble_cleanup(void) +{ + reassembly_table_destroy(&cotp_reassembly_table); +} + void proto_register_cotp(void) { static hf_register_info hf[] = { @@ -2428,6 +2434,7 @@ void proto_register_cotp(void) new_register_dissector("ositp_inactive", dissect_ositp_inactive, proto_cotp); register_init_routine(cotp_reassemble_init); + register_cleanup_routine(cotp_reassemble_cleanup); } void proto_register_cltp(void) diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c index 162011bce2..85b1f9ddac 100644 --- a/epan/dissectors/packet-pdcp-lte.c +++ b/epan/dissectors/packet-pdcp-lte.c @@ -2227,25 +2227,6 @@ static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree * file is loaded or re-loaded in wireshark */ static void pdcp_lte_init_protocol(void) { - /* Destroy any existing hashes. */ - if (pdcp_sequence_analysis_channel_hash) { - g_hash_table_destroy(pdcp_sequence_analysis_channel_hash); - } - if (pdcp_lte_sequence_analysis_report_hash) { - g_hash_table_destroy(pdcp_lte_sequence_analysis_report_hash); - } - if (pdcp_security_hash) { - g_hash_table_destroy(pdcp_security_hash); - } - if (pdcp_security_result_hash) { - g_hash_table_destroy(pdcp_security_result_hash); - } - if (pdcp_security_key_hash) { - g_hash_table_destroy(pdcp_security_key_hash); - } - - - /* Now create them over */ pdcp_sequence_analysis_channel_hash = g_hash_table_new(g_direct_hash, g_direct_equal); pdcp_lte_sequence_analysis_report_hash = g_hash_table_new(pdcp_result_hash_func, pdcp_result_hash_equal); pdcp_security_hash = g_hash_table_new(pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal); @@ -2253,6 +2234,15 @@ static void pdcp_lte_init_protocol(void) pdcp_security_key_hash = g_hash_table_new(pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal); } +static void pdcp_lte_cleanup_protocol(void) +{ + g_hash_table_destroy(pdcp_sequence_analysis_channel_hash); + g_hash_table_destroy(pdcp_lte_sequence_analysis_report_hash); + g_hash_table_destroy(pdcp_security_hash); + g_hash_table_destroy(pdcp_security_result_hash); + g_hash_table_destroy(pdcp_security_key_hash); +} + void proto_register_pdcp(void) @@ -2703,6 +2693,7 @@ void proto_register_pdcp(void) &global_pdcp_check_integrity); register_init_routine(&pdcp_lte_init_protocol); + register_cleanup_routine(&pdcp_lte_cleanup_protocol); } void proto_reg_handoff_pdcp_lte(void) diff --git a/epan/dissectors/packet-pvfs2.c b/epan/dissectors/packet-pvfs2.c index 40fcc802dc..c4c435c57f 100644 --- a/epan/dissectors/packet-pvfs2.c +++ b/epan/dissectors/packet-pvfs2.c @@ -2916,13 +2916,16 @@ pvfs2_io_tracking_hash(gconstpointer k) static void pvfs2_io_tracking_init(void) { - if (pvfs2_io_tracking_value_table != NULL) - g_hash_table_destroy(pvfs2_io_tracking_value_table); - pvfs2_io_tracking_value_table = g_hash_table_new(pvfs2_io_tracking_hash, pvfs2_io_tracking_equal); } +static void +pvfs2_io_tracking_cleanup(void) +{ + g_hash_table_destroy(pvfs2_io_tracking_value_table); +} + static pvfs2_io_tracking_value_t * pvfs2_io_tracking_new_with_tag(guint64 tag, guint32 num) { @@ -3611,6 +3614,7 @@ proto_register_pvfs(void) expert_register_field_array(expert_pvfs, ei, array_length(ei)); register_init_routine(pvfs2_io_tracking_init); + register_cleanup_routine(pvfs2_io_tracking_cleanup); pvfs_module = prefs_register_protocol(proto_pvfs, NULL); prefs_register_bool_preference(pvfs_module, "desegment", diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c index 9d69909421..213b7ed66c 100644 --- a/epan/dissectors/packet-radius.c +++ b/epan/dissectors/packet-radius.c @@ -2066,15 +2066,15 @@ extern void radius_register_avp_dissector(guint32 vendor_id, guint32 attribute_i static void radius_init_protocol(void) { - if (radius_calls != NULL) - { - g_hash_table_destroy(radius_calls); - radius_calls = NULL; - } - radius_calls = g_hash_table_new(radius_call_hash, radius_call_equal); } +static void +radius_cleanup_protocol(void) +{ + g_hash_table_destroy(radius_calls); +} + static void register_radius_fields(const char* unused _U_) { hf_register_info base_hf[] = { { &hf_radius_req, @@ -2255,6 +2255,7 @@ proto_register_radius(void) proto_radius = proto_register_protocol("Radius Protocol", "RADIUS", "radius"); new_register_dissector("radius", dissect_radius, proto_radius); register_init_routine(&radius_init_protocol); + register_cleanup_routine(&radius_cleanup_protocol); radius_module = prefs_register_protocol(proto_radius, proto_reg_handoff_radius); prefs_register_string_preference(radius_module,"shared_secret","Shared Secret", "Shared secret used to decode User Passwords", diff --git a/epan/dissectors/packet-rlc-lte.c b/epan/dissectors/packet-rlc-lte.c index 69c2cc3321..e56713c85f 100644 --- a/epan/dissectors/packet-rlc-lte.c +++ b/epan/dissectors/packet-rlc-lte.c @@ -2983,32 +2983,22 @@ static void dissect_rlc_lte_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree * file is loaded or re-loaded in wireshark */ static void rlc_lte_init_protocol(void) { - /* Destroy any existing hashes. */ - if (sequence_analysis_channel_hash) { - g_hash_table_destroy(sequence_analysis_channel_hash); - } - if (sequence_analysis_report_hash) { - g_hash_table_destroy(sequence_analysis_report_hash); - } - if (repeated_nack_channel_hash) { - g_hash_table_destroy(repeated_nack_channel_hash); - } - if (repeated_nack_report_hash) { - g_hash_table_destroy(repeated_nack_report_hash); - } - if (reassembly_report_hash) { - g_hash_table_destroy(reassembly_report_hash); - } - - /* Now create them over */ sequence_analysis_channel_hash = g_hash_table_new(rlc_channel_hash_func, rlc_channel_equal); sequence_analysis_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal); - repeated_nack_channel_hash = g_hash_table_new(rlc_channel_hash_func, rlc_channel_equal); repeated_nack_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal); reassembly_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal); } +static void rlc_lte_cleanup_protocol(void) +{ + g_hash_table_destroy(sequence_analysis_channel_hash); + g_hash_table_destroy(sequence_analysis_report_hash); + g_hash_table_destroy(repeated_nack_channel_hash); + g_hash_table_destroy(repeated_nack_report_hash); + g_hash_table_destroy(reassembly_report_hash); +} + /* Configure number of PDCP SN bits to use for DRB channels */ void set_rlc_lte_drb_pdcp_seqnum_length(packet_info *pinfo, guint16 ueid, guint8 drbid, guint8 userplane_seqnum_length) @@ -3610,6 +3600,7 @@ void proto_register_rlc_lte(void) ue_parameters_tree = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); register_init_routine(&rlc_lte_init_protocol); + register_cleanup_routine(&rlc_lte_cleanup_protocol); } void proto_reg_handoff_rlc_lte(void) diff --git a/epan/dissectors/packet-rohc.c b/epan/dissectors/packet-rohc.c index 002731b093..655de03efc 100644 --- a/epan/dissectors/packet-rohc.c +++ b/epan/dissectors/packet-rohc.c @@ -2364,14 +2364,15 @@ static guint cid_hash_func(gconstpointer v) static void rohc_init_protocol(void) { - /* Destroy any existing hashes. */ - if (rohc_cid_hash) - g_hash_table_destroy(rohc_cid_hash); - - /* Now create them again */ rohc_cid_hash = g_hash_table_new(cid_hash_func, cid_hash_equal); } +static void +rohc_cleanup_protocol(void) +{ + g_hash_table_destroy(rohc_cid_hash); +} + void proto_register_rohc(void) { @@ -2979,6 +2980,7 @@ proto_register_rohc(void) rohc_handle = new_register_dissector("rohc", dissect_rohc, proto_rohc); register_init_routine(&rohc_init_protocol); + register_cleanup_routine(&rohc_cleanup_protocol); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_rohc, hf, array_length(hf)); diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index ff2abefdc0..6ade6eb7bd 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -3801,18 +3801,19 @@ dissect_rpc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) static void rpc_init_protocol(void) { - if (rpc_reassembly_table != NULL) { - g_hash_table_destroy(rpc_reassembly_table); - rpc_reassembly_table = NULL; - } - rpc_reassembly_table = g_hash_table_new(rpc_fragment_hash, rpc_fragment_equal); - reassembly_table_init(&rpc_fragment_table, &addresses_ports_reassembly_table_functions); } +static void +rpc_cleanup_protocol(void) +{ + reassembly_table_destroy(&rpc_fragment_table); + g_hash_table_destroy(rpc_reassembly_table); +} + /* will be called once from register.c at startup time */ void proto_register_rpc(void) @@ -4087,6 +4088,7 @@ proto_register_rpc(void) expert_rpc = expert_register_protocol(proto_rpc); expert_register_field_array(expert_rpc, ei, array_length(ei)); register_init_routine(&rpc_init_protocol); + register_cleanup_routine(&rpc_cleanup_protocol); rpc_module = prefs_register_protocol(proto_rpc, NULL); prefs_register_bool_preference(rpc_module, "desegment_rpc_over_tcp", diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c index 67d9b22372..65a8d92ec7 100644 --- a/epan/dissectors/packet-rsvp.c +++ b/epan/dissectors/packet-rsvp.c @@ -1945,12 +1945,15 @@ rsvp_hash(gconstpointer k) static void rsvp_init_protocol(void) { - if (rsvp_request_hash) - g_hash_table_destroy(rsvp_request_hash); - rsvp_request_hash = g_hash_table_new(rsvp_hash, rsvp_equal); } +static void +rsvp_cleanup_protocol(void) +{ + g_hash_table_destroy(rsvp_request_hash); +} + static const char* rsvp_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter _U_) { if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_IPv4)) @@ -9577,6 +9580,7 @@ proto_register_rsvp(void) /* Initialization routine for RSVP conversations */ register_init_routine(&rsvp_init_protocol); + register_cleanup_routine(&rsvp_cleanup_protocol); register_conversation_table(proto_rsvp, TRUE, rsvp_conversation_packet, rsvp_hostlist_packet); } diff --git a/epan/dissectors/packet-sbus.c b/epan/dissectors/packet-sbus.c index 0c8739de26..1e0cf524e9 100644 --- a/epan/dissectors/packet-sbus.c +++ b/epan/dissectors/packet-sbus.c @@ -593,12 +593,13 @@ static guint sbus_hash(gconstpointer v) /*Protocol initialisation*/ static void sbus_init_protocol(void){ - if (sbus_request_hash){ - g_hash_table_destroy(sbus_request_hash); - } sbus_request_hash = g_hash_table_new(sbus_hash, sbus_equal); } +static void sbus_cleanup_protocol(void){ + g_hash_table_destroy(sbus_request_hash); +} + /* check whether the packet looks like SBUS or not */ static gboolean is_sbus_pdu(tvbuff_t *tvb) @@ -2321,6 +2322,7 @@ proto_register_sbus(void) expert_sbus = expert_register_protocol(proto_sbus); expert_register_field_array(expert_sbus, ei, array_length(ei)); register_init_routine(&sbus_init_protocol); + register_cleanup_routine(&sbus_cleanup_protocol); } void diff --git a/epan/dissectors/packet-sccp.c b/epan/dissectors/packet-sccp.c index fe320c9405..31ad19b858 100644 --- a/epan/dissectors/packet-sccp.c +++ b/epan/dissectors/packet-sccp.c @@ -3495,6 +3495,12 @@ init_sccp(void) &addresses_reassembly_table_functions); } +static void +cleanup_sccp(void) +{ + reassembly_table_destroy(&sccp_xudt_msg_reassembly_table); +} + /* Register the protocol with Wireshark */ void proto_register_sccp(void) @@ -4123,6 +4129,7 @@ proto_register_sccp(void) &default_payload); register_init_routine(&init_sccp); + register_cleanup_routine(&cleanup_sccp); assocs = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index b6eb01edcf..6ad4619b1e 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -5114,6 +5114,12 @@ tcp_init(void) &addresses_ports_reassembly_table_functions); } +static void +tcp_cleanup(void) +{ + reassembly_table_destroy(&tcp_reassembly_table); +} + void proto_register_tcp(void) { @@ -6070,6 +6076,7 @@ proto_register_tcp(void) &tcp_exp_options_with_magic); register_init_routine(tcp_init); + register_cleanup_routine(tcp_cleanup); register_decode_as(&tcp_da); diff --git a/epan/dissectors/packet-zbee-nwk.c b/epan/dissectors/packet-zbee-nwk.c index e37cdbbda2..e0b0df6d17 100644 --- a/epan/dissectors/packet-zbee-nwk.c +++ b/epan/dissectors/packet-zbee-nwk.c @@ -60,6 +60,7 @@ static guint dissect_zbee_nwk_link_status(tvbuff_t *tvb, proto_tree *tree, static guint dissect_zbee_nwk_report (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset); static guint dissect_zbee_nwk_update (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset); static void proto_init_zbee_nwk (void); +static void proto_cleanup_zbee_nwk(void); void proto_register_zbee_nwk(void); void proto_reg_handoff_zbee_nwk(void); @@ -1942,6 +1943,7 @@ void proto_register_zbee_nwk(void) expert_register_field_array(expert_zbee_nwk, ei, array_length(ei)); register_init_routine(proto_init_zbee_nwk); + register_cleanup_routine(proto_cleanup_zbee_nwk); /* Register the protocol with Wireshark. */ proto_zbee_nwk = proto_register_protocol("ZigBee Network Layer", "ZigBee", ZBEE_PROTOABBREV_NWK); @@ -2011,17 +2013,19 @@ static void free_keyring_val(gpointer a) static void proto_init_zbee_nwk(void) { - /* Destroy the hash tables, if they exist. */ - if (zbee_nwk_map.short_table) g_hash_table_destroy(zbee_nwk_map.short_table); - if (zbee_nwk_map.long_table) g_hash_table_destroy(zbee_nwk_map.long_table); - if (zbee_table_nwk_keyring) g_hash_table_destroy(zbee_table_nwk_keyring); - - /* (Re)create the hash tables. */ zbee_nwk_map.short_table = g_hash_table_new(ieee802154_short_addr_hash, ieee802154_short_addr_equal); zbee_nwk_map.long_table = g_hash_table_new(ieee802154_long_addr_hash, ieee802154_long_addr_equal); zbee_table_nwk_keyring = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free_keyring_val); } /* proto_init_zbee_nwk */ +static void +proto_cleanup_zbee_nwk(void) +{ + g_hash_table_destroy(zbee_nwk_map.short_table); + g_hash_table_destroy(zbee_nwk_map.long_table); + g_hash_table_destroy(zbee_table_nwk_keyring); +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * |