summaryrefslogtreecommitdiffstats
path: root/qt-models/divelocationmodel.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-06-02 15:35:06 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-03 21:25:46 -0700
commitbe0a708db0b05f2b8a42f81d49020ca2e656b714 (patch)
tree1e6aecb3664999c657e9a12293d01d50854fdcd9 /qt-models/divelocationmodel.cpp
parent16ac0bc45d0eac6444e6f4cf9325105eeeb92bdd (diff)
downloadsubsurface-be0a708db0b05f2b8a42f81d49020ca2e656b714.tar.gz
Two if's to prevent null pointer dereferencing
I need these to prevent subsurface from segfaulting when opening a new log. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r--qt-models/divelocationmodel.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index edf15b707..3e17f4fe2 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -29,6 +29,9 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
return QVariant();
struct dive_site *ds = get_dive_site(index.row());
+ if (!ds)
+ return QVariant();
+
switch(role) {
case Qt::DisplayRole : return qPrintable(ds->name);
case DIVE_SITE_UUID : return ds->uuid;
@@ -77,7 +80,8 @@ bool LocationInformationModel::removeRows(int row, int count, const QModelIndex
beginRemoveRows(QModelIndex(), row, row);
struct dive_site *ds = get_dive_site(row);
- delete_dive_site(ds->uuid);
+ if (ds)
+ delete_dive_site(ds->uuid);
endRemoveRows();
return true;
}