Navigation Menu

Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1337 - joystick crash due to heap corruption with btnx
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 1, 2012
1 parent dd64a8a commit fbb89a1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/joystick/SDL_joystick.c
Expand Up @@ -427,6 +427,11 @@ SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
{
int posted;

/* Make sure we're not getting garbage events */
if (axis >= joystick->naxes) {
return 0;
}

/* Update internal joystick state */
joystick->axes[axis] = value;

Expand Down Expand Up @@ -454,6 +459,11 @@ SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value)
{
int posted;

/* Make sure we're not getting garbage events */
if (hat >= joystick->nhats) {
return 0;
}

/* Update internal joystick state */
joystick->hats[hat] = value;

Expand Down Expand Up @@ -482,6 +492,11 @@ SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball,
{
int posted;

/* Make sure we're not getting garbage events */
if (ball >= joystick->nballs) {
return 0;
}

/* Update internal mouse state */
joystick->balls[ball].dx += xrel;
joystick->balls[ball].dy += yrel;
Expand Down Expand Up @@ -526,6 +541,11 @@ SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state)
}
#endif /* !SDL_EVENTS_DISABLED */

/* Make sure we're not getting garbage events */
if (button >= joystick->nbuttons) {
return 0;
}

/* Update internal joystick state */
joystick->buttons[button] = state;

Expand Down

0 comments on commit fbb89a1

Please sign in to comment.