--- a/src/joystick/SDL_joystick.c Sat Dec 31 13:29:09 2011 -0500
+++ b/src/joystick/SDL_joystick.c Sun Jan 01 16:58:00 2012 -0500
@@ -427,6 +427,11 @@
{
int posted;
+ /* Make sure we're not getting garbage events */
+ if (axis >= joystick->naxes) {
+ return 0;
+ }
+
/* Update internal joystick state */
joystick->axes[axis] = value;
@@ -454,6 +459,11 @@
{
int posted;
+ /* Make sure we're not getting garbage events */
+ if (hat >= joystick->nhats) {
+ return 0;
+ }
+
/* Update internal joystick state */
joystick->hats[hat] = value;
@@ -482,6 +492,11 @@
{
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;
@@ -526,6 +541,11 @@
}
#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;