Skip to content

Commit fb66688

Browse files
connorjclarkSiegeLord
authored andcommitted
[osx] Fix possible corruption when joystick connects early
device_add_callback could fire before the joysticks vector is initialized if the controller is already enabled and connects instantly.
1 parent d226797 commit fb66688

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/macosx/hidjoy.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,8 @@ static bool init_joystick(void)
811811
CFRelease(criteria1);
812812
CFRelease(criteria);
813813

814+
_al_vector_init(&joysticks, sizeof(ALLEGRO_JOYSTICK_OSX *));
815+
814816
/* Register for plug/unplug notifications */
815817
IOHIDManagerRegisterDeviceMatchingCallback(
816818
hidManagerRef,
@@ -836,8 +838,6 @@ static bool init_joystick(void)
836838
kCFRunLoopDefaultMode
837839
);
838840

839-
_al_vector_init(&joysticks, sizeof(ALLEGRO_JOYSTICK_OSX *));
840-
841841
al_lock_mutex(add_mutex);
842842

843843
IOReturn ret = IOHIDManagerOpen(

0 commit comments

Comments
 (0)