aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ipsec.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-28 15:15:07 +0200
committerMichael Mann <mmann78@netscape.net>2015-07-03 23:37:40 +0000
commitba9aa3015f29f07bf81cdfebdfab54fdc379b94d (patch)
treeabe1a58ac119d8c64fe9656221aa2e3bcfe0034d /epan/dissectors/packet-ipsec.c
parentea46cf4f73c72bf343a5d07ba33166d696a3d1f6 (diff)
Split more init routines into init/cleanup functions
This patch is partially automatically generated, but are modified manually. In particular, assignments and function calls have been audited. Some debugging comments and ifdef'd prints have been removed. The lookup tables of the dcm and sip dissectors are now cleared. It is only called on reopening files anyway. The isakmp dissector is modified to use g_hash_table_new_full for destruction of its keys and values. Fix a memleak in ipsec dissector when libgcrypt is not enabled. Generated using https://git.lekensteyn.nl/peter/wireshark-notes/diff/one-off/cleanup-rewrite.py?id=3c6128ee266024d164650955f93c7740484abd68 (with AUDIT = True). Change-Id: I3fd910bdee663842ac0196334fe0189b67e251b0 Reviewed-on: https://code.wireshark.org/review/9225 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-ipsec.c')
-rw-r--r--epan/dissectors/packet-ipsec.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c
index b7cfac4bea..72a3a9628f 100644
--- a/epan/dissectors/packet-ipsec.c
+++ b/epan/dissectors/packet-ipsec.c
@@ -2307,6 +2307,12 @@ dissect_ipcomp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static void ipsec_init_protocol(void)
{
+ esp_sequence_analysis_hash = g_hash_table_new(word_hash_func, word_equal);
+ esp_sequence_analysis_report_hash = g_hash_table_new(word_hash_func, word_equal);
+}
+
+static void ipsec_cleanup_protocol(void)
+{
#ifdef HAVE_LIBGCRYPT
/* Free any SA records added by other dissectors */
guint n;
@@ -2315,25 +2321,13 @@ static void ipsec_init_protocol(void)
}
/* Free overall block of records */
- if (extra_esp_sa_records.num_records > 0) {
- g_free(extra_esp_sa_records.records);
- extra_esp_sa_records.records = NULL;
- }
+ g_free(extra_esp_sa_records.records);
+ extra_esp_sa_records.records = NULL;
extra_esp_sa_records.num_records = 0;
-
- /* Destroy any existing hashes. */
- if (esp_sequence_analysis_hash) {
- g_hash_table_destroy(esp_sequence_analysis_hash);
- }
- if (esp_sequence_analysis_report_hash) {
- g_hash_table_destroy(esp_sequence_analysis_report_hash);
- }
#endif
- /* Now create them over */
- esp_sequence_analysis_hash = g_hash_table_new(word_hash_func, word_equal);
- esp_sequence_analysis_report_hash = g_hash_table_new(word_hash_func, word_equal);
-
+ g_hash_table_destroy(esp_sequence_analysis_hash);
+ g_hash_table_destroy(esp_sequence_analysis_report_hash);
}
void
@@ -2543,6 +2537,7 @@ proto_register_ipsec(void)
#endif
register_init_routine(&ipsec_init_protocol);
+ register_cleanup_routine(&ipsec_cleanup_protocol);
register_dissector("esp", dissect_esp, proto_esp);
register_dissector("ah", dissect_ah, proto_ah);