From d9d1b2344605f81f714b9dcacf54ce40a7e420d2 Mon Sep 17 00:00:00 2001 From: kelteseth Date: Thu, 14 Dec 2017 14:08:03 +0100 Subject: [PATCH] Add range check --- src/installedlistmodel.cpp | 5 +++++ src/monitorlistmodel.cpp | 5 +++++ src/profilelistmodel.cpp | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/src/installedlistmodel.cpp b/src/installedlistmodel.cpp index b04e3b70..ceba75f0 100644 --- a/src/installedlistmodel.cpp +++ b/src/installedlistmodel.cpp @@ -15,6 +15,11 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const if (!index.isValid()) return QVariant(); + int row = index.row(); + if(row < 0 || row >= m_screenPlayFiles.count()) { + return QVariant(); + } + if (index.row() < rowCount()) switch (role) { case TitleRole: diff --git a/src/monitorlistmodel.cpp b/src/monitorlistmodel.cpp index f4f88aa2..a6de0ce5 100644 --- a/src/monitorlistmodel.cpp +++ b/src/monitorlistmodel.cpp @@ -57,6 +57,11 @@ QVariant MonitorListModel::data(const QModelIndex& index, int role) const if (!index.isValid()) return QVariant(); + int row = index.row(); + if(row < 0 || row >= m_monitorList.count()) { + return QVariant(); + } + if (index.row() < rowCount()) switch (role) { case IDRole: diff --git a/src/profilelistmodel.cpp b/src/profilelistmodel.cpp index ce8c551f..dddd5ff1 100644 --- a/src/profilelistmodel.cpp +++ b/src/profilelistmodel.cpp @@ -28,6 +28,10 @@ QVariant ProfileListModel::data(const QModelIndex& index, int role) const return QVariant(); int row = index.row(); + if(row < 0 || row >= m_profileList.count()) { + return QVariant(); + } + if (row < 0 || row >= m_profileList.count()) { return QVariant(); }