ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Memory leaks when using epan

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Fri, 20 Aug 2010 20:39:50 -0700
On Aug 20, 2010, at 11:53 AM, Jeff Morriss wrote:

> The valgrind output shows that Valgrind thinks the ep_ and se_ allocated 
> memory is being leaked.  Sounds like you need to call ep_free_all() 
> (after each packet) and se_free_all() (when the file is closed).
> 
> Normally the former is done in epan_dissect_run() and the latter is done 
> in cleanup_dissection() (or init_dissection()).  Not sure how that 
> relates to your code.

It doesn't, because he directly calls call_dissector_only().

We don't guarantee that calling call_dissector_only() from code outside libwireshark will work the way you want.  If he's trying to do the same sort of dissection Wireshark does, he should do it the same way that Wireshark does it, by using the routines declared in <epan/epan.h>.  If, as I suspect from his code he's trying to do, he's using a *particular* dissector, he should, for now:

	copy the code from dissect_packet() in epan/packet.c into his own private routine, and have it call the mp2t dissector instead of the frame dissector;

	copy the code from epan_dissect_run() in epan/epan.c into his own private routine, and have it call his private modified version of dissect_packet() rather than calling dissect_packet();

although I can't guarantee that'll work, either, if the copied code is calling static routines from epan/packet.c, for example.