Better fix, iterate backwards over the array so we don't care whether the close code shuffles things down.

This commit is contained in:
Sam Lantinga 2011-11-29 02:27:34 -05:00
parent 22e0d6fa53
commit f98e88676c

View file

@ -403,8 +403,8 @@ SDL_JoystickQuit(void)
/* Stop the event polling */ /* Stop the event polling */
SDL_numjoysticks = 0; SDL_numjoysticks = 0;
for (i = 0; i < numsticks; i++) { for (i = numjoysticks; i--; ) {
SDL_Joystick *stick = SDL_joysticks[0]; SDL_Joystick *stick = SDL_joysticks[i];
if (stick && (stick->ref_count >= 1)) { if (stick && (stick->ref_count >= 1)) {
stick->ref_count = 1; stick->ref_count = 1;
SDL_JoystickClose(stick); SDL_JoystickClose(stick);