Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: Re: [Ethereal-dev] patch to pcap-util.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxx>
Date: Sat, 5 Jul 2003 17:10:19 -0700
On Fri, Jul 04, 2003 at 10:15:43AM -0400, Nathan Jennings wrote:
> I think I found a memory leak in pcap-util's free_interface_list(). I 
> think g_list_remove_link() is the wrong function to use here.

Yes, but...

> It isolates a list element from the current list. So, only one element was 
> being freed each time it was called.

...the consequence isn't that only one element gets freed, the
consequence is that all the data items attached to the list elements get
freed (as we iterate on what's left of the list after removing the
element), but *NONE* of the list elements themselves get freed (because
"g_list_remove_link()", as its documentation says, "Removes an element
from a GList, *without* freeing the element".

> See attached patch.

Checked in (plus a change to use "free_interface_list()" in some code
that used to do

	g_list_foreach(il, free_if_cb, NULL);
	g_list_free(il);

itself, now that "free_interface_list()" does that).