Wireshark mailing list archives

Re: Memory leaks when using epan


From: Guy Harris <guy () alum mit edu>
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.
___________________________________________________________________________
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: