diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-06-30 12:08:54 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-07-03 07:58:00 +0000 |
commit | 536e26c55ecd89825855b14b7edd9899dfe6a78c (patch) | |
tree | a7f5575f7433521917eb846b1abb478b4cf9f91a /ui/qt/main_window_slots.cpp | |
parent | 8a1e517befc032b5607ca34ea60399db5d2359c4 (diff) |
Qt: fix crash on opening a capture file while loading/saving another
Closing a capture file while it is being loaded will result in a crash.
As a workaround, disallow closing the capture file. The requested action
(e.g. MainWindow::openCaptureFile) will be silently ignored.
While at it, protect process_specified_records (called when saving
files) similarly to cf_read and fix a crash that occurs when a capture
from the Capture Dialog is started while a file is being loaded:
file.c:360:cf_close: assertion failed: (cf->state != FILE_READ_IN_PROGRESS)
Bug: 10870 # moving rapidly between large files in a file set
Bug: 13594 # start capture while loading/saving file
Bug: 14351 # open another file while loading file
Change-Id: I6ce8f3163c3fa4869f0299e49909a32594326ce4
Reviewed-on: https://code.wireshark.org/review/28541
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/main_window_slots.cpp')
-rw-r--r-- | ui/qt/main_window_slots.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index c209752a89..fd920b488f 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -200,6 +200,10 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned } } + // TODO detect call from "cf_read" -> "update_progress_dlg" + // ("capture_file_.capFile()->read_lock"), possibly queue opening the + // file and return early to avoid the warning in testCaptureFileClose. + QString before_what(tr(" before opening another file")); if (!testCaptureFileClose(before_what)) { ret = false; @@ -1384,9 +1388,12 @@ void MainWindow::startInterfaceCapture(bool valid, const QString capture_filter) { capture_filter_valid_ = valid; welcome_page_->setCaptureFilter(capture_filter); - // The interface tree will update the selected interfaces via its timer - // so no need to do anything here. - startCapture(); + QString before_what(tr(" before starting a new capture")); + if (testCaptureFileClose(before_what)) { + // The interface tree will update the selected interfaces via its timer + // so no need to do anything here. + startCapture(); + } } void MainWindow::applyGlobalCommandLineOptions() @@ -3716,7 +3723,10 @@ void MainWindow::gotoFrame(int packet_num) void MainWindow::extcap_options_finished(int result) { if (result == QDialog::Accepted) { - startCapture(); + QString before_what(tr(" before starting a new capture")); + if (testCaptureFileClose(before_what)) { + startCapture(); + } } this->welcome_page_->getInterfaceFrame()->interfaceListChanged(); } |