Closing a capture file has nothing to do with the list of interfaces on
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 13 Mar 2012 03:48:27 +0000 (03:48 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 13 Mar 2012 03:48:27 +0000 (03:48 +0000)
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.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@41517 f5534014-38df-0310-8fa8-9805f1628bb7

capture_opts.c
ui/gtk/main.c

index f2ee8245bf96f5771be6a5a885b5d1808ceab376..64749fb91d17fa5943a76a9b2fa46f1e03bdcbb9 100644 (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) {
index ffabe3db9e5066329d9950a884c931b081bd49d2..20112c577be5ff28a6e53c62268e3da682f50bf1 100644 (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");