Don't create a packet dialog if we don't have a packet.
Move the "find the frame" stuff to openPacketDialog(), and don't even bother creating a new PacketDialog if we don't find the frame. This should squelch Coverity CID 1270934, by giving up quickly if fdata is null. Change-Id: I4605ba7e271a55724f02cafed4122f9dd9b1b6f7 Reviewed-on: https://code.wireshark.org/review/7467 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
3108bf8d2e
commit
99ceab898c
|
@ -2022,12 +2022,29 @@ void MainWindow::on_actionViewResizeColumns_triggered()
|
|||
|
||||
void MainWindow::openPacketDialog(bool from_reference)
|
||||
{
|
||||
PacketDialog *packet_dialog = new PacketDialog(*this, capture_file_, from_reference);
|
||||
connect(this, SIGNAL(monospaceFontChanged(QFont)),
|
||||
packet_dialog, SIGNAL(monospaceFontChanged(QFont)));
|
||||
zoomText(); // Emits monospaceFontChanged
|
||||
frame_data * fdata;
|
||||
|
||||
packet_dialog->show();
|
||||
/* Find the frame for which we're popping up a dialog */
|
||||
if(from_reference) {
|
||||
guint32 framenum = fvalue_get_uinteger(&(capture_file_.capFile()->finfo_selected->value));
|
||||
if (framenum == 0)
|
||||
return;
|
||||
|
||||
fdata = frame_data_sequence_find(capture_file_.capFile()->frames, framenum);
|
||||
} else {
|
||||
fdata = capture_file_.capFile()->current_frame;
|
||||
}
|
||||
|
||||
/* If we have a frame, pop up the dialog */
|
||||
if (fdata) {
|
||||
PacketDialog *packet_dialog = new PacketDialog(*this, capture_file_, fdata);
|
||||
|
||||
connect(this, SIGNAL(monospaceFontChanged(QFont)),
|
||||
packet_dialog, SIGNAL(monospaceFontChanged(QFont)));
|
||||
zoomText(); // Emits monospaceFontChanged
|
||||
|
||||
packet_dialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewShowPacketInNewWindow_triggered()
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
// - Copy over experimental packet editing code.
|
||||
// - Fix ElidedText width.
|
||||
|
||||
PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, bool from_reference) :
|
||||
PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata) :
|
||||
WiresharkDialog(parent, cf),
|
||||
ui(new Ui::PacketDialog),
|
||||
packet_data_(NULL)
|
||||
|
@ -53,16 +53,6 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, bool from_reference
|
|||
// XXX Use recent settings instead
|
||||
resize(parent.width() * 4 / 5, parent.height() * 4 / 5);
|
||||
|
||||
frame_data * fdata = cap_file_.capFile()->current_frame;
|
||||
|
||||
if(from_reference) {
|
||||
guint32 framenum = fvalue_get_uinteger(&(cap_file_.capFile()->finfo_selected->value));
|
||||
if (framenum < 1) reject();
|
||||
|
||||
fdata = frame_data_sequence_find(cap_file_.capFile()->frames, framenum);
|
||||
}
|
||||
if (!fdata) reject();
|
||||
|
||||
setWindowSubtitle(tr("Packet %1").arg(fdata->num));
|
||||
|
||||
phdr_ = cap_file_.capFile()->phdr;
|
||||
|
|
|
@ -39,7 +39,7 @@ class PacketDialog : public WiresharkDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PacketDialog(QWidget &parent, CaptureFile &cf, bool from_reference = false);
|
||||
explicit PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata);
|
||||
~PacketDialog();
|
||||
|
||||
signals:
|
||||
|
|
Loading…
Reference in New Issue