aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-04-26 13:13:54 +0200
committerPeter Wu <peter@lekensteyn.nl>2018-04-26 16:41:34 +0000
commitf9522d8a23a375ddc8bd39cf556002cdec346ab1 (patch)
treed8f7d6d6e0b0458555555d886e10f048b21480b3 /ui
parentcfc15838bdecb44ce1a17d47ad015cb9a1e8962c (diff)
Qt: fix crash on dragging in packet dialog
"packet_dialog.cpp" does not use setCaptureFile, resulting in a NULL dereference while trying to obtain the dissection context. Apply a fix similar to v2.5.1rc0-121-g9198448f9d (pass a fixed dissection context to ProtoTree). Additionally, fix a memleak and correct documentation. Why not add "proto_tree_->setCaptureFile(cap_file_.capFile())" in PacketDialog? Well, it also uses "proto_tree_->setRootNode(edt_.tree)" which means that "cf_->edt" would be different from "edt_". If that is the case, then "proto_construct_match_selected_string" will not return a filter for FT_NONE fields (see the call chain in proto.c). Bug: 14620 Change-Id: I6eeaf32b650a2095e15f64bbe64b54cdd545c7a9 Fixes: v2.5.0rc0-1608-g4d6454e180 ("Qt: Drag n Drop Filter expression from Packet Tree") Reviewed-on: https://code.wireshark.org/review/27160 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/packet_dialog.cpp4
-rw-r--r--ui/qt/proto_tree.cpp16
-rw-r--r--ui/qt/proto_tree.h3
3 files changed, 17 insertions, 6 deletions
diff --git a/ui/qt/packet_dialog.cpp b/ui/qt/packet_dialog.cpp
index 3d6a4fc375..e35ec88885 100644
--- a/ui/qt/packet_dialog.cpp
+++ b/ui/qt/packet_dialog.cpp
@@ -69,7 +69,9 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata)
fdata, &(cap_file_.capFile()->cinfo));
epan_dissect_fill_in_columns(&edt_, TRUE, TRUE);
- proto_tree_ = new ProtoTree(ui->packetSplitter);
+ proto_tree_ = new ProtoTree(ui->packetSplitter, &edt_);
+ // Do not call proto_tree_->setCaptureFile, ProtoTree only needs the
+ // dissection context.
proto_tree_->setRootNode(edt_.tree);
byte_view_tab_ = new ByteViewTab(ui->packetSplitter, &edt_);
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index 5d5f7509ac..26ffa2d38a 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -33,12 +33,13 @@
// To do:
// - Fix "apply as filter" behavior.
-ProtoTree::ProtoTree(QWidget *parent) :
+ProtoTree::ProtoTree(QWidget *parent, epan_dissect_t *edt_fixed) :
QTreeView(parent),
proto_tree_model_(new ProtoTreeModel(this)),
decode_as_(NULL),
column_resize_timer_(0),
- cap_file_(NULL)
+ cap_file_(NULL),
+ edt_(edt_fixed)
{
setAccessibleName(tr("Packet details"));
// Leave the uniformRowHeights property as-is (false) since items might
@@ -518,12 +519,16 @@ const QString ProtoTree::toString(const QModelIndex &start_idx) const
void ProtoTree::setCaptureFile(capture_file *cf)
{
+ // For use by the main view, set the capture file which will later have a
+ // dissection (EDT) ready.
+ // The packet dialog sets a fixed EDT context and MUST NOT use this.
+ Q_ASSERT(edt_ == NULL);
cap_file_ = cf;
}
bool ProtoTree::eventFilter(QObject * obj, QEvent * event)
{
- if ( cap_file_ && event->type() != QEvent::MouseButtonPress && event->type() != QEvent::MouseMove )
+ if ( event->type() != QEvent::MouseButtonPress && event->type() != QEvent::MouseMove )
return QTreeView::eventFilter(obj, event);
/* Mouse was over scrollbar, ignoring */
@@ -554,7 +559,10 @@ bool ProtoTree::eventFilter(QObject * obj, QEvent * event)
emit fieldSelected(&finfo);
selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
- QString filter = QString(proto_construct_match_selected_string(finfo.fieldInfo(), cap_file_->edt));
+ epan_dissect_t *edt = cap_file_ ? cap_file_->edt : edt_;
+ char *field_filter = proto_construct_match_selected_string(finfo.fieldInfo(), edt);
+ QString filter(field_filter);
+ wmem_free(NULL, field_filter);
if ( filter.length() > 0 )
{
diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h
index 9dada379eb..6ed2e6ebb5 100644
--- a/ui/qt/proto_tree.h
+++ b/ui/qt/proto_tree.h
@@ -29,7 +29,7 @@ class ProtoTree : public QTreeView
{
Q_OBJECT
public:
- explicit ProtoTree(QWidget *parent = 0);
+ explicit ProtoTree(QWidget *parent = 0, epan_dissect_t *edt_fixed = 0);
QMenu *colorizeMenu() { return &colorize_menu_; }
void setRootNode(proto_node *root_node);
void emitRelatedFrame(int related_frame, ft_framenum_type_t framenum_type = FT_FRAMENUM_NONE);
@@ -62,6 +62,7 @@ private:
QPoint drag_start_position_;
capture_file *cap_file_;
+ epan_dissect_t *edt_;
void saveSelectedField(QModelIndex &index);
static void foreachTreeNode(proto_node *node, gpointer proto_tree_ptr);