зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403185 - Fix button value index lookup oob for Windows Gamepads; r=ted
We can get button indexes in HID usage reports that do not actually correspond to a button we store, meaning we can overstep bounds of the button array. Check validity before accessing array. MozReview-Commit-ID: AAQJLEgy2Ua --HG-- extra : rebase_source : d665f7713612b76f7b36ca3d2ace1e6659bb5099
This commit is contained in:
Родитель
4d16000195
Коммит
3ccc401fc9
|
@ -860,6 +860,11 @@ WindowsGamepadService::HandleRawInput(HRAWINPUT handle)
|
|||
memset(buttons.Elements(), 0, gamepad->numButtons * sizeof(bool));
|
||||
|
||||
for (unsigned i = 0; i < usageLength; i++) {
|
||||
// The button index in usages may be larger than what we detected when
|
||||
// enumerating gamepads. If so, warn and continue.
|
||||
if (NS_WARN_IF((usages[i] - 1) >= buttons.Length())) {
|
||||
continue;
|
||||
}
|
||||
buttons[usages[i] - 1] = true;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче