From 55316365d8a97f0a40e3822622c0613bc599bf1f Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 10 Dec 2021 16:51:41 +0100 Subject: [PATCH] Fixed an issue where buggy controller drivers could crash the application. --- CHANGELOG.md | 1 + es-core/src/InputManager.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa78a2843..3fbf2004e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -129,6 +129,7 @@ Apart from all the above, a huge amount of work has gone into fixing bugs, refac * Single-scraping a game, aborting and then re-scraping without leaving the metadata editor would sometimes lead to a crash * Setting a really small font size in a theme would crash the application * Deleting the last custom collection could crash the application if the grouped "collections" system was set as the startup gamelist +* Connecting a controller with buggy drivers could crash the application * Setting an invalid UIMode value in the configuration file could crash the application * Setting an invalid scraper service value in the configuration file could crash the application * When scraping in interactive mode with "Auto-accept single game matches" enabled, the game name could not be refined if there were no games found diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index dac5d0c49..e1514c065 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -625,6 +625,12 @@ void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex) { // Open joystick and add it to our list. SDL_GameController* controller = SDL_GameControllerOpen(deviceIndex); + + if (controller == nullptr) { + LOG(LogError) << "Couldn't add controller with device index " << deviceIndex; + return; + } + SDL_Joystick* joy = SDL_GameControllerGetJoystick(controller); // Add it to our list so we can close it again later.