aboutsummaryrefslogtreecommitdiffstats
path: root/epan/packet.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-08-28 12:42:59 +0100
committerAnders Broman <a.broman58@gmail.com>2017-08-29 03:53:04 +0000
commitc7290277311f5189e4341c7684e14118f9f21c8b (patch)
treeb8927c0e9309b1ecee1c6497b9db17031ed40da9 /epan/packet.c
parent1f9990b7657332daad0680107d5230e18437f1da (diff)
epan: Properly cleanup registered postdissectors
wanted_hfids member was never properly freed. Fix indentation too. Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2198 Bug: 13996 Change-Id: I8297df2158fd0ae8123223f4622ae952a218a07a Reviewed-on: https://code.wireshark.org/review/23167 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/packet.c')
-rw-r--r--epan/packet.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/epan/packet.c b/epan/packet.c
index 5952cbea92..542277db24 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -264,8 +264,14 @@ packet_cleanup(void)
g_hash_table_destroy(heuristic_short_names);
g_slist_foreach(shutdown_routines, &call_routine, NULL);
g_slist_free(shutdown_routines);
- if (postdissectors)
+ if (postdissectors) {
+ for (guint i = 0; i < postdissectors->len; i++) {
+ if (POSTDISSECTORS(i).wanted_hfids) {
+ g_array_free(POSTDISSECTORS(i).wanted_hfids, TRUE);
+ }
+ }
g_array_free(postdissectors, TRUE);
+ }
}
/*
@@ -3285,31 +3291,37 @@ register_postdissector(dissector_handle_t handle)
void
set_postdissector_wanted_hfids(dissector_handle_t handle, GArray *wanted_hfids)
{
- guint i;
+ guint i;
- if (!postdissectors) return;
+ if (!postdissectors) return;
- for (i = 0; i < postdissectors->len; i++) {
- if (POSTDISSECTORS(i).handle == handle) {
- POSTDISSECTORS(i).wanted_hfids = wanted_hfids;
- break;
- }
- }
+ for (i = 0; i < postdissectors->len; i++) {
+ if (POSTDISSECTORS(i).handle == handle) {
+ if (POSTDISSECTORS(i).wanted_hfids) {
+ g_array_free(POSTDISSECTORS(i).wanted_hfids, TRUE);
+ }
+ POSTDISSECTORS(i).wanted_hfids = wanted_hfids;
+ break;
+ }
+ }
}
void
deregister_postdissector(dissector_handle_t handle)
{
- guint i;
+ guint i;
- if (!postdissectors) return;
+ if (!postdissectors) return;
- for (i = 0; i < postdissectors->len; i++) {
- if (POSTDISSECTORS(i).handle == handle) {
- postdissectors = g_array_remove_index_fast(postdissectors, i);
- break;
- }
- }
+ for (i = 0; i < postdissectors->len; i++) {
+ if (POSTDISSECTORS(i).handle == handle) {
+ if (POSTDISSECTORS(i).wanted_hfids) {
+ g_array_free(POSTDISSECTORS(i).wanted_hfids, TRUE);
+ }
+ postdissectors = g_array_remove_index_fast(postdissectors, i);
+ break;
+ }
+ }
}
gboolean