Преглед изворни кода

input_common: Fix crash when controller disconnects

german77 пре 5 година
родитељ
комит
edd498f6e0
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      src/input_common/sdl/sdl_impl.cpp

+ 3 - 1
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) {