From 70fd8e2ba29522dfeaa897dc4a37ab59f8b25f92 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 19 Oct 2023 22:35:53 -0700 Subject: [PATCH] Lock joysticks when adding gamepad mappings Fixes https://github.com/libsdl-org/SDL/issues/8412 --- src/joystick/SDL_gamepad.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index 6bb982c57..1af2159a5 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -1670,6 +1670,8 @@ int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc) } line = buf; + SDL_LockJoysticks(); + PushMappingChangeTracking(); while (line < buf + db_size) { @@ -1702,6 +1704,8 @@ int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc) PopMappingChangeTracking(); + SDL_UnlockJoysticks(); + SDL_free(buf); return gamepads; }