From db5cd8c694086c4bd54bee52cec48e4b8907fd51 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Sat, 12 Jun 2021 14:57:34 +0100 Subject: [PATCH] joystick: virtual: Fix event injection for axes/hats SDL_JoystickSetVirtualAxisInner() and SDL_JoystickSetVirtualHatInner() did not properly sanitize the 'axis' and 'hat' parameters. Signed-off-by: Paul Cercueil --- src/joystick/virtual/SDL_virtualjoystick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index ec1c42cc3..be32b2de1 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -176,7 +176,7 @@ SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value) } hwdata = (joystick_hwdata *)joystick->hwdata; - if (axis < 0 || axis >= hwdata->nbuttons) { + if (axis < 0 || axis >= hwdata->naxes) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid axis index"); } @@ -226,7 +226,7 @@ SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value) } hwdata = (joystick_hwdata *)joystick->hwdata; - if (hat < 0 || hat >= hwdata->nbuttons) { + if (hat < 0 || hat >= hwdata->nhats) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid hat index"); }