Don't call pcap_breakloop() if we're not capturing anything. Fixes a
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 26 May 2011 22:12:27 +0000 (22:12 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 26 May 2011 22:12:27 +0000 (22:12 +0000)
crash found by Stig.

Add debugging output to capture_cleanup_handler() on non-Windows
systems.

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

dumpcap.c

index 4deb4f1a49f42acdd1a863fde08250309642fc25..74a60adb0805f7ee78a6b16177a1464df6faed5d 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -1365,7 +1365,7 @@ capture_cleanup_handler(DWORD dwCtrlType)
 }
 #else
 static void
-capture_cleanup_handler(int signum _U_)
+capture_cleanup_handler(int signum)
 {
     /* On UN*X, we cleanly shut down the capture on SIGINT, SIGHUP, and
        SIGTERM.  We assume that if the user wanted it to keep running
@@ -1376,6 +1376,11 @@ capture_cleanup_handler(int signum _U_)
      * the "recursion" and abort.
      */
 
+    g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_INFO,
+        "Console: Control signal");
+    g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
+        "Console: Control signal %d", signum);
+
     capture_loop_stop();
 }
 #endif
@@ -3482,10 +3487,12 @@ static void capture_loop_stop(void)
     guint i;
     pcap_options *pcap_opts;
 
-    for (i = 0; i < global_ld.pcaps->len; i++) {
-        pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i);
-        if (pcap_opts->pcap_h != NULL)
-            pcap_breakloop(pcap_opts->pcap_h);
+    if (global_ld.pcaps) {
+        for (i = 0; i < global_ld.pcaps->len; i++) {
+            pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i);
+            if (pcap_opts->pcap_h != NULL)
+                pcap_breakloop(pcap_opts->pcap_h);
+        }
     }
 #endif
     global_ld.go = FALSE;