From edd498f6e0c8343a1368bdb49f5f8a4919ff89f0 Mon Sep 17 00:00:00 2001 From: german77 Date: Fri, 14 May 2021 21:56:39 -0500 Subject: input_common: Fix crash when controller disconnects --- src/input_common/sdl/sdl_impl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index c918a333d..288557968 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -267,7 +267,9 @@ void SDLState::CloseJoystick(SDL_Joystick* sdl_joystick) { return joystick->GetSDLJoystick() == sdl_joystick; }); - (*joystick_it)->SetSDLJoystick(nullptr, nullptr); + if (joystick_it != joystick_guid_list.end()) { + (*joystick_it)->SetSDLJoystick(nullptr, nullptr); + } } void SDLState::HandleGameControllerEvent(const SDL_Event& event) { -- cgit v1.2.3