diff --git a/app/gui/appmodel.cpp b/app/gui/appmodel.cpp index 668f36c1..aeb4b39e 100644 --- a/app/gui/appmodel.cpp +++ b/app/gui/appmodel.cpp @@ -13,7 +13,7 @@ void AppModel::initialize(ComputerManager* computerManager, int computerIndex, b connect(m_ComputerManager, &ComputerManager::computerStateChanged, this, &AppModel::handleComputerStateChanged); - Q_ASSERT(computerIndex < m_ComputerManager->getComputers().count()); + Q_ASSERT(computerIndex >= 0 && computerIndex < m_ComputerManager->getComputers().count()); m_Computer = m_ComputerManager->getComputers().at(computerIndex); m_CurrentGameId = m_Computer->currentGameId; m_ShowHiddenGames = showHiddenGames; @@ -41,7 +41,7 @@ QString AppModel::getRunningAppName() Session* AppModel::createSessionForApp(int appIndex) { - Q_ASSERT(appIndex < m_VisibleApps.count()); + Q_ASSERT(appIndex >= 0 && appIndex < m_VisibleApps.count()); NvApp app = m_VisibleApps.at(appIndex); return new Session(m_Computer, app); @@ -73,7 +73,7 @@ QVariant AppModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); - Q_ASSERT(index.row() < m_VisibleApps.count()); + Q_ASSERT(index.row() >= 0 && index.row() < m_VisibleApps.count()); NvApp app = m_VisibleApps.at(index.row()); switch (role) @@ -207,7 +207,7 @@ void AppModel::updateAppList(QVector newList) void AppModel::setAppHidden(int appIndex, bool hidden) { - Q_ASSERT(appIndex < m_VisibleApps.count()); + Q_ASSERT(appIndex >= 0 && appIndex < m_VisibleApps.count()); int appId = m_VisibleApps.at(appIndex).id; { @@ -226,7 +226,7 @@ void AppModel::setAppHidden(int appIndex, bool hidden) void AppModel::setAppDirectLaunch(int appIndex, bool directLaunch) { - Q_ASSERT(appIndex < m_VisibleApps.count()); + Q_ASSERT(appIndex >= 0 && appIndex < m_VisibleApps.count()); int appId = m_VisibleApps.at(appIndex).id; { diff --git a/app/gui/computermodel.cpp b/app/gui/computermodel.cpp index 4e3aae31..fac61292 100644 --- a/app/gui/computermodel.cpp +++ b/app/gui/computermodel.cpp @@ -22,7 +22,7 @@ QVariant ComputerModel::data(const QModelIndex& index, int role) const return QVariant(); } - Q_ASSERT(index.row() < m_Computers.count()); + Q_ASSERT(index.row() >= 0 && index.row() < m_Computers.count()); NvComputer* computer = m_Computers[index.row()]; QReadLocker lock(&computer->lock); @@ -116,7 +116,7 @@ QHash ComputerModel::roleNames() const Session* ComputerModel::createSessionForCurrentGame(int computerIndex) { - Q_ASSERT(computerIndex < m_Computers.count()); + Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count()); NvComputer* computer = m_Computers[computerIndex]; @@ -136,7 +136,7 @@ Session* ComputerModel::createSessionForCurrentGame(int computerIndex) void ComputerModel::deleteComputer(int computerIndex) { - Q_ASSERT(computerIndex < m_Computers.count()); + Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count()); beginRemoveRows(QModelIndex(), computerIndex, computerIndex); @@ -166,7 +166,7 @@ private: void ComputerModel::wakeComputer(int computerIndex) { - Q_ASSERT(computerIndex < m_Computers.count()); + Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count()); DeferredWakeHostTask* wakeTask = new DeferredWakeHostTask(m_Computers[computerIndex]); QThreadPool::globalInstance()->start(wakeTask); @@ -174,7 +174,7 @@ void ComputerModel::wakeComputer(int computerIndex) void ComputerModel::renameComputer(int computerIndex, QString name) { - Q_ASSERT(computerIndex < m_Computers.count()); + Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count()); m_ComputerManager->renameHost(m_Computers[computerIndex], name); } @@ -215,7 +215,7 @@ void ComputerModel::testConnectionForComputer(int) void ComputerModel::pairComputer(int computerIndex, QString pin) { - Q_ASSERT(computerIndex < m_Computers.count()); + Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count()); m_ComputerManager->pairHost(m_Computers[computerIndex], pin); } diff --git a/app/streaming/streamutils.cpp b/app/streaming/streamutils.cpp index 6c0e8222..ec209d43 100644 --- a/app/streaming/streamutils.cpp +++ b/app/streaming/streamutils.cpp @@ -266,7 +266,7 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode, CGDirectDisplayID displayIds[MAX_DISPLAYS]; uint32_t displayCount = 0; CGGetActiveDisplayList(MAX_DISPLAYS, displayIds, &displayCount); - if (displayIndex >= (int)displayCount) { + if (displayIndex < 0 || displayIndex >= (int)displayCount) { return false; } @@ -343,7 +343,7 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode, #else SDL_assert(SDL_WasInit(SDL_INIT_VIDEO)); - if (displayIndex >= SDL_GetNumVideoDisplays()) { + if (displayIndex < 0 || displayIndex >= SDL_GetNumVideoDisplays()) { return false; }