From 4faae3a671594a9a1a8153280e118446c1f84b87 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 2 Jun 2015 15:35:06 +0200 Subject: [PATCH] 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 --- qt-models/divelocationmodel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index edf15b7..3e17f4f 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; } -- 2.3.2 (Apple Git-55)