Skip to content

Commit

Permalink
joystick: Quit drivers in reverse order to ensure dependencies are no…
Browse files Browse the repository at this point in the history
…t broken

SDL_WINDOWS_JoystickDriver depends on callbacks in SDL_RAWINPUT_JoystickDriver
and SDL_HIDAPI_JoystickDriver being available. It also manages the common
WindowProc used for joystick detection in both WINDOWS and RAWINPUT drivers.

If we don't tear them down backwards, there's a window of time where we could
invoke RAWINPUT_WindowProc() after RAWINPUT_JoystickQuit() was called.
  • Loading branch information
cgutman committed Nov 19, 2021
1 parent b679659 commit 1237142
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/joystick/SDL_joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,8 @@ SDL_JoystickQuit(void)
SDL_JoystickClose(SDL_joysticks);
}

/* Quit the joystick setup */
for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) {
/* Quit drivers in reverse order to avoid breaking dependencies between drivers */
for (i = SDL_arraysize(SDL_joystick_drivers) - 1; i >= 0; --i) {
SDL_joystick_drivers[i]->Quit();
}

Expand Down

0 comments on commit 1237142

Please sign in to comment.