From 94b3f78c440bfd52182848adf39db71325861e9c Mon Sep 17 00:00:00 2001 From: Mathieu Eyraud <70028899+meyraud705@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:05:29 +0200 Subject: [PATCH] Fix out of bound read of 'has_hat' array --- src/joystick/linux/SDL_sysjoystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 777aac50a5..cca2016e50 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -1149,7 +1149,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) } for (i = 0; i < ABS_MAX; ++i) { /* Skip digital hats */ - if (joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) { + if (i >= ABS_HAT0X && i <= ABS_HAT3Y && joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) { continue; } if (test_bit(i, absbit)) {