Skip to content

Commit

Permalink
Merge pull request #4797 from JoergAtGithub/hidoutputreportiteratorfix
Browse files Browse the repository at this point in the history
Prevent incrementing map iterator, when iterator points to map end
  • Loading branch information
daschuer committed Jun 12, 2022
2 parents 326ea88 + d26deb6 commit cd7452c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/controllers/hid/hidiothread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,13 @@ bool HidIoThread::sendNextCachedOutputReport() {
// which only has the effect, that one additional lookup operation for unsent data will be executed.
for (unsigned char i = 0; i < m_outputReports.size(); i++) {
auto mapLock = lockMutex(&m_outputReportMapMutex);
m_outputReportIterator++;
if (m_outputReportIterator == m_outputReports.end()) {
m_outputReportIterator = m_outputReports.begin();
} else {
m_outputReportIterator++;
if (m_outputReportIterator == m_outputReports.end()) {
m_outputReportIterator = m_outputReports.begin();
}
}
mapLock.unlock();

Expand Down

0 comments on commit cd7452c

Please sign in to comment.