Skip to content

Commit db5cd8c

Browse files
pcercueisezero
authored andcommitted
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 <[email protected]>
1 parent f3cf019 commit db5cd8c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/joystick/virtual/SDL_virtualjoystick.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value)
176176
}
177177

178178
hwdata = (joystick_hwdata *)joystick->hwdata;
179-
if (axis < 0 || axis >= hwdata->nbuttons) {
179+
if (axis < 0 || axis >= hwdata->naxes) {
180180
SDL_UnlockJoysticks();
181181
return SDL_SetError("Invalid axis index");
182182
}
@@ -226,7 +226,7 @@ SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value)
226226
}
227227

228228
hwdata = (joystick_hwdata *)joystick->hwdata;
229-
if (hat < 0 || hat >= hwdata->nbuttons) {
229+
if (hat < 0 || hat >= hwdata->nhats) {
230230
SDL_UnlockJoysticks();
231231
return SDL_SetError("Invalid hat index");
232232
}

0 commit comments

Comments
 (0)