[SDL] segfault when trying to close joystick

Justin Coleman jmcoleman at gmail.com
Mon Mar 11 08:49:25 PDT 2013


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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130311/e9be23f5/attachment-0008.htm>


More information about the SDL mailing list