aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2022-04-27 15:09:32 +0200
committerAlessandro Portale <alessandro.portale@qt.io>2022-04-28 08:36:00 +0000
commit1811b381ebe195262a14bda86852aca055b99245 (patch)
tree21ff78a43c6b75998029aa4e16861750ffa24e04
parenta984e9c097fe950acbfe1e960783634363182158 (diff)
ProjectExplorer: Prevent out of range access on recent projects list
ProjectExplorerPlugin::recentProjects() filters out non-existent files. Because files could at any time be removed/renamed, we cannot presume a certain, constant length of the list when calling recentProjects() a second time. Fixes: QTCREATORBUG-27399 Change-Id: I3f09830896b308e251881c855abb552b6022695f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--src/plugins/projectexplorer/projectwelcomepage.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp
index e1adf657ad..2382103d91 100644
--- a/src/plugins/projectexplorer/projectwelcomepage.cpp
+++ b/src/plugins/projectexplorer/projectwelcomepage.cpp
@@ -83,7 +83,10 @@ int ProjectModel::rowCount(const QModelIndex &) const
QVariant ProjectModel::data(const QModelIndex &index, int role) const
{
- QPair<QString,QString> data = ProjectExplorerPlugin::recentProjects().at(index.row());
+ const QList<QPair<QString, QString> > recentProjects = ProjectExplorerPlugin::recentProjects();
+ if (recentProjects.count() <= index.row())
+ return {};
+ QPair<QString, QString> data = recentProjects.at(index.row());
switch (role) {
case Qt::DisplayRole:
return data.second;