Better fix, iterate backwards over the array so we don't care whether the close code shuffles things down.
--- a/src/joystick/SDL_joystick.c Tue Nov 29 02:15:39 2011 -0500
+++ b/src/joystick/SDL_joystick.c Tue Nov 29 02:27:34 2011 -0500
@@ -403,8 +403,8 @@
/* Stop the event polling */
SDL_numjoysticks = 0;
- for (i = 0; i < numsticks; i++) {
- SDL_Joystick *stick = SDL_joysticks[0];
+ for (i = numjoysticks; i--; ) {
+ SDL_Joystick *stick = SDL_joysticks[i];
if (stick && (stick->ref_count >= 1)) {
stick->ref_count = 1;
SDL_JoystickClose(stick);