From 89abbbfe9ed2b19b018515cd9c9aadadaddf1a82 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 7 Oct 2016 18:24:34 -0700 Subject: [PATCH] Fixed bug 3438 - SDL_GameControllerEventWatcher: Log on event with value >= k_nMaxReverseEntries --- src/joystick/SDL_gamecontroller.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 41af66d7a..1d3a4c203 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -145,7 +145,11 @@ int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event) { SDL_GameController *controllerlist; - if (event->jaxis.axis >= k_nMaxReverseEntries) break; + if (event->jaxis.axis >= k_nMaxReverseEntries) + { + SDL_SetError("SDL_GameControllerEventWatcher: Axis index %d too large, ignoring motion", (int)event->jaxis.axis); + break; + } controllerlist = SDL_gamecontrollers; while (controllerlist) { @@ -176,7 +180,11 @@ int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event) { SDL_GameController *controllerlist; - if (event->jbutton.button >= k_nMaxReverseEntries) break; + if (event->jbutton.button >= k_nMaxReverseEntries) + { + SDL_SetError("SDL_GameControllerEventWatcher: Button index %d too large, ignoring update", (int)event->jbutton.button); + break; + } controllerlist = SDL_gamecontrollers; while (controllerlist) {