From 15fb6158bca814d9cd223e6068d1addc2a88cc88 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 9 Jan 2015 12:03:29 -0800 Subject: 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 --- qt-ui/downloadfromdivecomputer.cpp | 5 +++-- 1 file 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(); } -- cgit v1.2.3-70-g09d2