fix: Wrong m_buttons vector size in case of maxButton inferior to numButtons

This commit is contained in:
Corentin Rossignon 2025-08-01 12:32:44 +02:00 committed by Chris Rizzitello
parent f73d098b1f
commit 11caf55522

View file

@ -1863,7 +1863,7 @@ void XWindowsScreen::updateButtons()
}
// allocate button array
m_buttons.resize(maxButton);
m_buttons.resize(std::max<size_t>(maxButton, numButtons));
// fill in button array values. m_buttons[i] is the physical
// button number for logical button i+1.
@ -1871,7 +1871,9 @@ void XWindowsScreen::updateButtons()
m_buttons[i] = 0;
}
for (uint32_t i = 0; i < numButtons; ++i) {
m_buttons[tmpButtons[i] - 1] = i + 1;
if (tmpButtons[i] > 0) {
m_buttons[tmpButtons[i] - 1] = i + 1;
}
}
// clean up