From b683dbc52de959ca743ebafa0d00d63743740fa1 Mon Sep 17 00:00:00 2001 From: Mara van der Laan <126646+laanwj@users.noreply.github.com> Date: Wed, 11 Feb 2026 14:39:35 +0100 Subject: [PATCH] io: Fix crash on SDL joystick disconnect Check that `pJoystick[i]` is non-null before dereferencing it. --- code/io/joy-sdl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/io/joy-sdl.cpp b/code/io/joy-sdl.cpp index 3d653550e70..8327170bb19 100644 --- a/code/io/joy-sdl.cpp +++ b/code/io/joy-sdl.cpp @@ -558,7 +558,7 @@ bool device_event_handler(const SDL_Event &evt) // Else, Find if any of our joysticks were lost for (short i = CID_JOY0; i < CID_JOY_MAX; ++i) { - if (joyDeviceEvent.which == pJoystick[i]->getID()) + if (pJoystick[i] != nullptr && joyDeviceEvent.which == pJoystick[i]->getID()) { // We just lost our joystick, reset the data mprintf(("Joystick %i disconnected\n", i));