aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-04-19 12:37:50 +0200
committerRoland Knall <rknall@gmail.com>2018-04-20 07:46:00 +0000
commit01a32a54a01a5711ebef0850830aed9fc9d657f6 (patch)
treeefccce0c6d0b1fa37431f91a2ac5d44a0f11a26a
parent0a130c5756eda79cbb55f1d38824fbaf9d1abc68 (diff)
Qt: fix invalid member access within expert info dialog
Opening a context menu in the expert dialog resulted in an UBSAN warning because ExpertInfoModel::data is invoked with a proxy model index. Rely on the proxy to perform this mapping (change filterActionTriggered to avoid direct model access while at it). Change-Id: Id399f44b954b87d7d4dd0341fbedb391ab1b13da Fixes: v2.5.0rc0-1966-gb0112e60ad ("Add a model to use for Expert Info dialog.") Reviewed-on: https://code.wireshark.org/review/27025 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r--ui/qt/expert_info_dialog.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/ui/qt/expert_info_dialog.cpp b/ui/qt/expert_info_dialog.cpp
index 5b7407ea1d..4dddfecf11 100644
--- a/ui/qt/expert_info_dialog.cpp
+++ b/ui/qt/expert_info_dialog.cpp
@@ -237,9 +237,11 @@ void ExpertInfoDialog::showExpertInfoMenu(QPoint pos)
{
bool enable = true;
QModelIndex expertIndex = ui->expertInfoTreeView->indexAt(pos);
+ if (!expertIndex.isValid()) {
+ return;
+ }
- if (!expertIndex.isValid() ||
- (expert_info_model_->data(expertIndex.sibling(expertIndex.row(), ExpertInfoModel::colHf), Qt::DisplayRole).toInt() < 0)) {
+ if (proxyModel_->data(expertIndex.sibling(expertIndex.row(), ExpertInfoModel::colHf), Qt::DisplayRole).toInt() < 0) {
enable = false;
}
@@ -260,27 +262,26 @@ void ExpertInfoDialog::showExpertInfoMenu(QPoint pos)
void ExpertInfoDialog::filterActionTriggered()
{
- QModelIndex packetIndex = ui->expertInfoTreeView->currentIndex();
+ QModelIndex modelIndex = ui->expertInfoTreeView->currentIndex();
FilterAction *fa = qobject_cast<FilterAction *>(QObject::sender());
- if (!fa || !packetIndex.isValid()) {
+ if (!fa || !modelIndex.isValid()) {
return;
}
- QModelIndex modelIndex = proxyModel_->mapToSource(packetIndex);
- int hf_index = expert_info_model_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colHf), Qt::DisplayRole).toInt();
+ int hf_index = proxyModel_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colHf), Qt::DisplayRole).toInt();
if (hf_index > -1) {
QString filter_string;
if (fa->action() == FilterAction::ActionWebLookup) {
filter_string = QString("%1 %2")
- .arg(expert_info_model_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colProtocol), Qt::DisplayRole).toString())
- .arg(expert_info_model_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colSummary), Qt::DisplayRole).toString());
+ .arg(proxyModel_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colProtocol), Qt::DisplayRole).toString())
+ .arg(proxyModel_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colSummary), Qt::DisplayRole).toString());
} else if (fa->action() == FilterAction::ActionCopy) {
filter_string = QString("%1 %2: %3")
- .arg(expert_info_model_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colPacket), Qt::DisplayRole).toUInt())
- .arg(expert_info_model_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colProtocol), Qt::DisplayRole).toString())
- .arg(expert_info_model_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colSummary), Qt::DisplayRole).toString());
+ .arg(proxyModel_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colPacket), Qt::DisplayRole).toUInt())
+ .arg(proxyModel_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colProtocol), Qt::DisplayRole).toString())
+ .arg(proxyModel_->data(modelIndex.sibling(modelIndex.row(), ExpertInfoModel::colSummary), Qt::DisplayRole).toString());
} else {
filter_string = proto_registrar_get_abbrev(hf_index);
}