Fixed bug #638 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Sep 2009 11:34:50 +0000
branchSDL-1.2
changeset 4226 dbdf8b108e31
parent 4225 6c1d2039b6b4
child 4227 c5ee6a0d7916
Fixed bug #638 Philipp Nordhus 2008-11-05 13:56:33 PST The Linux version of SDL_SYS_JoystickQuit() tries to free an invalid pointer when the number of joysticks was reduced since the last call. Reproduce: Connect two joysticks, call SDL_Init() and SDL_Quit(), then disconnect one joystick and call the functions again.
src/joystick/linux/SDL_sysjoystick.c
--- a/src/joystick/linux/SDL_sysjoystick.c	Mon Sep 21 11:32:58 2009 +0000
+++ b/src/joystick/linux/SDL_sysjoystick.c	Mon Sep 21 11:34:50 2009 +0000
@@ -1191,8 +1191,8 @@
 
 	for ( i=0; SDL_joylist[i].fname; ++i ) {
 		SDL_free(SDL_joylist[i].fname);
+		SDL_joylist[i].fname = NULL;
 	}
-	SDL_joylist[0].fname = NULL;
 }
 
 #endif /* SDL_JOYSTICK_LINUX */