Wireshark mailing list archives
Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c
From: Jakub Zawadzki <darkjames-ws () darkjames pl>
Date: Wed, 10 Oct 2012 16:46:35 +0200
On Wed, Oct 10, 2012 at 10:10:08AM -0400, Evan Huus wrote:
I still think that https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5284#c26 would also fix the problem, and we just unnecessary overcomplicate allocator.Is that not the same idea Guy and Jeff discussed that earlier in the bug (comments 2 through 6)?
2-4? For me comment #3 is invalid (sorry Jeff :>),
packet_list_dissect_and_cache_record is using own edt structure, and
cfile has other one.
So if cfile->edt->pi.data_src and name will be g_malloced I don't see a problem.
Don't have time to write proper patch, but I think about smth like this:
epan/packet.c
@@ -206,22 +206,16 @@ add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name)
{
data_source *src;
- src = ep_alloc(sizeof (data_source));
+ src = g_malloc(sizeof (data_source));
src->tvb = tvb;
- src->name_initialized = FALSE;
- src->name = name;
+ src->name = g_strdup(name);
pinfo->data_src = g_slist_append(pinfo->data_src, src);
}
const char*
get_data_source_name(data_source *src)
{
- if (!src->name_initialized) {
- src->name = ep_strdup_printf("%s (%u bytes)", src->name, tvb_length(src->tvb));
- src->name_initialized = TRUE;
- }
-
- return src->name;
+ return ep_strdup_printf("%s (%u bytes)", src->name, tvb_length(src->tvb));
}
/*
@@ -231,6 +225,7 @@ void
free_data_sources(packet_info *pinfo)
{
if (pinfo->data_src) {
+ /* XXX, g_free src->name, src */
g_slist_free(pinfo->data_src);
pinfo->data_src = NULL;
}
We also need to check if Qt allocate own copy of get_data_source_name(). Gtk AFAIR does.
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Evan Huus (Oct 10)
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Evan Huus (Oct 10)
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Jakub Zawadzki (Oct 10)
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Evan Huus (Oct 10)
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Jakub Zawadzki (Oct 10)
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Evan Huus (Oct 10)
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Jakub Zawadzki (Oct 10)
- Re: [Wireshark-commits] rev 45445: /trunk/epan/ /trunk/epan/: emem.c Evan Huus (Oct 10)
- for developing an application protocol dissector based on IEEE 802.11 Song, Eugene (Oct 10)
