aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-09 12:03:29 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-09 12:41:38 -0800
commit15fb6158bca814d9cd223e6068d1addc2a88cc88 (patch)
tree5f52b91fb3635fcaa0876607acef4d8d210af955 /qt-ui/downloadfromdivecomputer.cpp
parentcd2cee4974a413a9fd462b4115d92b3c633f1a44 (diff)
downloadsubsurface-15fb6158bca814d9cd223e6068d1addc2a88cc88.tar.gz
Dive d/l selection UI: the indices are inclusive, allocate enough space
The array we allocated was one entry too small. On the flip side, let's just make sure we cannot call this with a negative range. That would be bad, too. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 44ea3881f..e78270ab0 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -629,14 +629,15 @@ Qt::ItemFlags DiveImportedModel::flags(const QModelIndex &index) const
void DiveImportedModel::setImportedDivesIndexes(int first, int last)
{
+ Q_ASSERT(last >= first);
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);
endRemoveRows();
beginInsertRows(QModelIndex(), 0, last - first);
lastIndex = last;
firstIndex = first;
delete[] checkStates;
- checkStates = new bool[last - first];
- memset(checkStates, true, last - first);
+ checkStates = new bool[last - first + 1];
+ memset(checkStates, true, last - first + 1);
endInsertRows();
}