Closing a capture file has nothing to do with the list of interfaces on

which to do a live capture; don't clear the latter list when closing the
capture file.

collect_ifaces() should clear out the existing list of interfaces before
filling that list up with the interfaces selected by the user.  In
addition, when it frees up interfaces in that list, it should free up
the strings attached to those interfaces.

svn path=/trunk/; revision=41517
This commit is contained in:
Guy Harris 2012-03-13 03:48:27 +00:00
parent 07e797272e
commit fa64659e93
2 changed files with 19 additions and 12 deletions

View File

@ -975,6 +975,25 @@ collect_ifaces(capture_options *capture_opts)
guint i;
interface_t device;
interface_options interface_opts;
/* Empty out the existing list of interfaces. */
for (i = capture_opts->ifaces->len; i != 0; i--) {
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i - 1);
g_free(interface_opts.name);
g_free(interface_opts.descr);
g_free(interface_opts.cfilter);
#ifdef HAVE_PCAP_REMOTE
if (interface_opts.src_type == CAPTURE_IFREMOTE) {
g_free(interface_opts.remote_host);
g_free(interface_opts.remote_port);
g_free(interface_opts.auth_username);
g_free(interface_opts.auth_password);
}
#endif
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i - 1);
}
/* Now fill the list up again. */
for (i = 0; i < capture_opts->all_ifaces->len; i++) {
device = g_array_index(capture_opts->all_ifaces, interface_t, i);
if (!device.hidden && device.selected) {

View File

@ -1403,10 +1403,6 @@ npf_warning_dialog_cb(gpointer dialog, gint btn _U_, gpointer data _U_)
static void
main_cf_cb_file_closing(capture_file *cf)
{
#ifdef HAVE_LIBPCAP
int i;
#endif
/* if we have more than 10000 packets, show a splash screen while closing */
/* XXX - don't know a better way to decide whether to show or not,
* as most of the time is spend in a single eth_clist_clear function,
@ -1424,14 +1420,6 @@ main_cf_cb_file_closing(capture_file *cf)
destroy_packet_wins();
file_save_as_destroy();
#ifdef HAVE_LIBPCAP
if (global_capture_opts.ifaces && global_capture_opts.ifaces->len > 0) {
for (i = (int)global_capture_opts.ifaces->len-1; i >= 0; i--) {
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
}
}
#endif
/* Restore the standard title bar message. */
set_main_window_name("The Wireshark Network Analyzer");