mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Fixes an out of bounds joystick array access
Testing with an Xbox Series X controller. The extra button they added directly under the Xbox button emits 0xA7 for me, which is lower than BTN_MISC. As a result, when pressed, handleKeyEvent was indexing an array with a negative index. This commit adds a bounds check preventing the negative index, and adds a second bounds check to a similar function preemptively. It's possible that the better fix for this is to extend the range of the buttons array so that this button can be mapped, but that may need some disucssion first.
This commit is contained in:
parent
b35641f4a3
commit
5e1ec2444f
@ -49,6 +49,7 @@
|
||||
//
|
||||
static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
|
||||
{
|
||||
if (code < BTN_MISC || code >= KEY_CNT - BTN_MISC) return;
|
||||
_glfwInputJoystickButton(js,
|
||||
js->linjs.keyMap[code - BTN_MISC],
|
||||
value ? GLFW_PRESS : GLFW_RELEASE);
|
||||
@ -58,6 +59,7 @@ static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
|
||||
//
|
||||
static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
|
||||
{
|
||||
if (code >= ABS_CNT) return;
|
||||
const int index = js->linjs.absMap[code];
|
||||
|
||||
if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
|
||||
|
Loading…
Reference in New Issue
Block a user