diff options
author | Thiago Macieira <thiago@macieira.org> | 2014-05-07 21:51:55 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-07 21:52:56 -0700 |
commit | 497d6e3e6c353d69cd6c27f7b573400b82de8ff3 (patch) | |
tree | b95563b74f6e3dbb8b3cd85d0d4f49a771993cd4 /qt-ui/divelistview.cpp | |
parent | 5bd6361f918f9f1d9c8ff16df0511a42113847d7 (diff) | |
download | subsurface-497d6e3e6c353d69cd6c27f7b573400b82de8ff3.tar.gz |
Fix crash on dereferencing dangling pointers
QList::first() returns a reference to an item, but that list was a
temporary. The list gets destroyed at the end of the statement (the
semi-colon), so we ended up keeping a reference to freed data (i.e., a
dangling pointer)
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 8c1c6a3ed..00906c6b4 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -275,7 +275,7 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection) connect(selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex))); Q_EMIT currentDiveChanged(selected_dive); - const QModelIndex &idx = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, selected_dive, 2, Qt::MatchRecursive).first(); + QModelIndex idx = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, selected_dive, 2, Qt::MatchRecursive).first(); if (idx.parent().isValid()) scrollTo(idx.parent()); scrollTo(idx); |