From 0a05b281f235819c36d6c2bc13e313a8e5ea09c6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 7 Sep 2022 11:51:16 -0700 Subject: [PATCH] Make sure we hold the joystick lock when updating the device state while opening it --- src/joystick/SDL_joystick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index dfa8877d4..509a4c477 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -573,8 +573,6 @@ SDL_JoystickOpen(int device_index) joystick->next = SDL_joysticks; SDL_joysticks = joystick; - SDL_UnlockJoysticks(); - /* send initial battery event */ initial_power_level = joystick->epowerlevel; joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN; @@ -582,6 +580,8 @@ SDL_JoystickOpen(int device_index) driver->Update(joystick); + SDL_UnlockJoysticks(); + return joystick; }