Fixed bug #638 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Sep 2009 11:34:50 +0000
branchSDL-1.2
changeset 4226dbdf8b108e31
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
     1.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Mon Sep 21 11:32:58 2009 +0000
     1.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Mon Sep 21 11:34:50 2009 +0000
     1.3 @@ -1191,8 +1191,8 @@
     1.4  
     1.5  	for ( i=0; SDL_joylist[i].fname; ++i ) {
     1.6  		SDL_free(SDL_joylist[i].fname);
     1.7 +		SDL_joylist[i].fname = NULL;
     1.8  	}
     1.9 -	SDL_joylist[0].fname = NULL;
    1.10  }
    1.11  
    1.12  #endif /* SDL_JOYSTICK_LINUX */