From 748687252337c4e8ab0e5488f609deb56d21950f Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Thu, 26 Apr 2012 08:41:47 +0000 Subject: [PATCH] Refcount edt.s as we may have atleast two "active" edt:s in certain circumstances see bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5284 patch by Evan Huus svn path=/trunk/; revision=42254 --- epan/epan.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/epan/epan.c b/epan/epan.c index 3778f066a7..538026007f 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -71,6 +71,13 @@ #include "geoip_db.h" #endif +/* + * Refcount the edt:s and don't free ep memory until refcount = 0 + * See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5284 + * + */ +static guint edt_refs = 0; + const gchar* epan_get_version(void) { return VERSION; @@ -174,6 +181,8 @@ epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const g edt->pi.dependent_frames = NULL; + edt_refs++; + return edt; } @@ -198,9 +207,6 @@ void epan_dissect_run(epan_dissect_t *edt, void* pseudo_header, const guint8* data, frame_data *fd, column_info *cinfo) { - /* free all memory allocated during previous packet */ - ep_free_all(); - dissect_packet(edt, pseudo_header, data, fd, cinfo); } @@ -220,6 +226,11 @@ epan_dissect_cleanup(epan_dissect_t* edt) if (edt->tree) { proto_tree_free(edt->tree); } + + edt_refs--; + + if (edt_refs == 0) + ep_free_all(); } void