summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2015-06-24 15:41:22 -0700
committerAnders Broman <a.broman58@gmail.com>2015-06-25 15:55:36 +0000
commitcb840222963f4986a831d5d6f9eb28d1d45083f6 (patch)
treef2bdb1babecf770ce0564cbab356ff95cd356e9a
parent1810112f2d93d862c8b558279f5537e4db0fa4ad (diff)
downloadwireshark-cb840222963f4986a831d5d6f9eb28d1d45083f6.tar.gz
Qt: fix crashes when Wireshark is closed while running a capture
if we haven't captured any packets yet, don't display a warning about unsaved changes make sure that we're not running into a scenario where MainWindow::testCaptureFileClose() tries to close the capture file at the same time as the pipe handler who sees an eof on the pipe cf_has_unsaved_data() should return false if we have a temporary file that contains no packets Change-Id: I18d75bd658b85d45dd3313d49e2cd654c6300de5 Reviewed-on: https://code.wireshark.org/review/9109 Reviewed-by: Evan Huus <eapache@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Gerald Combs <gerald@wireshark.org> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--file.c2
-rw-r--r--ui/qt/main_window.cpp3
2 files changed, 3 insertions, 2 deletions
diff --git a/file.c b/file.c
index 4755394963..39f500448c 100644
--- a/file.c
+++ b/file.c
@@ -4336,7 +4336,7 @@ cf_has_unsaved_data(capture_file *cf)
* If this is a temporary file, or a file with unsaved changes, it
* has unsaved data.
*/
- return cf->is_tempfile || cf->unsaved_changes;
+ return (cf->is_tempfile && cf->count>0) || cf->unsaved_changes;
}
/*
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 2754714c75..abae150c71 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -1334,7 +1334,7 @@ bool MainWindow::testCaptureFileClose(bool from_quit, QString &before_what) {
return true; /* Already closed, nothing to do */
#ifdef HAVE_LIBPCAP
- if (capture_file_.capFile()->state == FILE_READ_IN_PROGRESS) {
+ if (capture_file_.capFile()->state == FILE_READ_IN_PROGRESS && capture_file_.capFile()->count>0) {
/* This is true if we're reading a capture file *or* if we're doing
a live capture. If we're reading a capture file, the main loop
is busy reading packets, and only accepting input from the
@@ -1459,6 +1459,7 @@ bool MainWindow::testCaptureFileClose(bool from_quit, QString &before_what) {
} else {
/* Unchanged file, just close it */
+ capture_file_.capFile()->state = FILE_READ_ABORTED;
cf_close(capture_file_.capFile());
}
} else {