forked from osmocom/wireshark
From Nathan Jennings: "g_list_remove_link()" doesn't free the list item
itself, so we leaked memory when freeing the interface list; in "free_interface_list()", use "g_list_foreach()", calling a list free routine, to free the data items in the list, and then use "g_list_free()" to free the list. Use "free_interface_list()" in "get_interface_list()" to free the list if we have an error, as it now does what the code that use to be there did. svn path=/trunk/; revision=7965
This commit is contained in:
parent
33bdfd46d7
commit
a99b2c3b2b
1
AUTHORS
1
AUTHORS
|
@ -1758,6 +1758,7 @@ And assorted fixes and enhancements by the people listed above and by:
|
|||
Marcio Franco <franco.marcio [AT] rd.francetelecom.fr>
|
||||
Kaloian Stoilov <kalkata [AT] yahoo.com>
|
||||
Steven Lass <stevenlass [AT] mail.com>
|
||||
Nathan Jennings <njen [AT] bellsouth.net>
|
||||
|
||||
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to
|
||||
give his permission to use his version of snprintf.c.
|
||||
|
|
|
@ -1842,6 +1842,7 @@ B<http://www.ethereal.com>.
|
|||
Marcio Franco <franco.marcio [AT] rd.francetelecom.fr>
|
||||
Kaloian Stoilov <kalkata [AT] yahoo.com>
|
||||
Steven Lass <stevenlass [AT] mail.com>
|
||||
Nathan Jennings <njen [AT] bellsouth.net>
|
||||
|
||||
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to give his
|
||||
permission to use his version of snprintf.c.
|
||||
|
|
14
pcap-util.c
14
pcap-util.c
|
@ -1,7 +1,7 @@
|
|||
/* pcap-util.c
|
||||
* Utility routines for packet capture
|
||||
*
|
||||
* $Id: pcap-util.c,v 1.13 2003/06/13 02:37:42 guy Exp $
|
||||
* $Id: pcap-util.c,v 1.14 2003/07/06 00:07:58 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -381,10 +381,8 @@ get_interface_list(int *err, char *err_str)
|
|||
return il;
|
||||
|
||||
fail:
|
||||
if (il != NULL) {
|
||||
g_list_foreach(il, free_if_cb, NULL);
|
||||
g_list_free(il);
|
||||
}
|
||||
if (il != NULL)
|
||||
free_interface_list(il);
|
||||
g_free(ifc.ifc_buf);
|
||||
close(sock);
|
||||
*err = CANT_GET_INTERFACE_LIST;
|
||||
|
@ -519,10 +517,8 @@ free_if_cb(gpointer data, gpointer user_data _U_)
|
|||
void
|
||||
free_interface_list(GList *if_list)
|
||||
{
|
||||
while (if_list != NULL) {
|
||||
g_free(if_list->data);
|
||||
if_list = g_list_remove_link(if_list, if_list);
|
||||
}
|
||||
g_list_foreach(if_list, free_if_cb, NULL);
|
||||
g_list_free(if_list);
|
||||
}
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
|
Loading…
Reference in New Issue