[SDL] segfault when trying to close joystick

Sik the hedgehog sik.the.hedgehog at gmail.com
Mon Mar 11 09:03:47 PDT 2013


The problem is that close(joystick->hwdata->fd) shouldn't result in
joystick->hwdata becoming NULL, and if it reaches that line it
obviously isn't NULL because of the if right before that.

2013/3/11, Justin Coleman <jmcoleman at gmail.com>:
> If joystick->hwdata is NULL, then you can't access joystick->hwdata->item
> at all.
>
> On Sun, Mar 10, 2013 at 12:01 PM, nescivi <nescivi at gmail.com> wrote:
>
>> **
>> Hi,
>>
>> I'm running into a bug when I try to close a joystick.
>>
>> In SDL_sysjoystick.c (around line 984) it crashes just after the close(
>> joystick->hwdata->fd ), when the function returns from this,
>> joystick->hwdata is reset to a NULL pointer, and the following if
>> statement
>> crashes.
>>
>> I'm not sure why this happens...
>>
>> sincerely,
>> Marije
>>
>> void
>> SDL_SYS_JoystickClose(SDL_Joystick * joystick)
>> {
>> if (joystick->hwdata) {
>> close(joystick->hwdata->fd);
>> if (joystick->hwdata->item) {
>> joystick->hwdata->item->hwdata = NULL;
>> }
>>
>> _______________________________________________
>> SDL mailing list
>> SDL at lists.libsdl.org
>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>>
>>
>



More information about the SDL mailing list