qt: Fix crash when stopping an empty live capture

When the capture process has not yet received any packets (not even the
libpcap header), Wireshark-Qt would crash because no valid capture file
was found. Reproducer:

    ssh otherhost sleep 10000 | wireshark -k -i -

GTK displays "Waiting for capture input data" in the status bar until
the capture file format is determined. After this patch, both versions
will just display an "Interrupted system call" message.

Change-Id: I146f00c0f4fcab04cddcd4f29b56e97b807a9c40
Reviewed-on: https://code.wireshark.org/review/10388
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: ronnie sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Peter Wu 2015-09-04 23:38:46 +02:00 committed by ronnie sahlberg
parent df3fd2dc69
commit fd342f7f73
1 changed files with 7 additions and 5 deletions

View File

@ -242,11 +242,13 @@ void MainStatusBar::expertUpdate() {
// ui/gtk/main_statusbar.c
void MainStatusBar::setFileName(CaptureFile &cf)
{
popFileStatus();
QString msgtip = QString("%1 (%2)")
.arg(cf.capFile()->filename)
.arg(file_size_to_qstring(cf.capFile()->f_datalen));
pushFileStatus(cf.fileName(), msgtip);
if (cf.isValid()) {
popFileStatus();
QString msgtip = QString("%1 (%2)")
.arg(cf.capFile()->filename)
.arg(file_size_to_qstring(cf.capFile()->f_datalen));
pushFileStatus(cf.fileName(), msgtip);
}
}
void MainStatusBar::setCaptureFile(capture_file *cf)