From 82b2c849f0873b52a9820b7cae9395b4f7f8e654 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Mon, 21 Jan 2019 23:41:43 +0100 Subject: [PATCH] Fixed bug 4024 - GameController error "Unexpected controller element" If mapping string is terminated with a comma, there is no more values to parse. --- src/joystick/SDL_gamecontroller.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 9ac3af5fa..15af7ab9b 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -676,8 +676,10 @@ SDL_PrivateGameControllerParseControllerConfigString(SDL_GameController *gamecon pchPos++; } - SDL_PrivateGameControllerParseElement(gamecontroller, szGameButton, szJoystickButton); - + /* No more values if the string was terminated by a comma. Don't report an error. */ + if (szGameButton[0] != '\0' || szJoystickButton[0] != '\0') { + SDL_PrivateGameControllerParseElement(gamecontroller, szGameButton, szJoystickButton); + } } /*