Fixed bug 2562 - SDL_hapticlist/_tail not set correctly
authorSam Lantinga
Sat, 21 Jun 2014 20:40:00 -0700
changeset 89025192470456ae
parent 8900 537445b25e4e
child 8903 8e09eceea61e
Fixed bug 2562 - SDL_hapticlist/_tail not set correctly

Zachary L

SDL_hapticlist and SDL_hapticlist_tail are not set correctly when quitting the subsystem. This matters because they are represented as global variables. In the case you quit and reinitialize the subsystems, problems with dangling pointers arise.

For instance, SDL_hapticlist_tail will not be null on second initialization and because of the check on line 298, it will fail to set SDL_hapticlist appropriately. This can cause a few things to go wrong, like feeding SDL_strcmp a null fname which can cause a segfault.
src/haptic/linux/SDL_syshaptic.c
     1.1 --- a/src/haptic/linux/SDL_syshaptic.c	Sat Jun 21 20:35:36 2014 -0700
     1.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Sat Jun 21 20:40:00 2014 -0700
     1.3 @@ -624,6 +624,8 @@
     1.4  #endif /* SDL_USE_LIBUDEV */
     1.5  
     1.6      numhaptics = 0;
     1.7 +    SDL_hapticlist = NULL;
     1.8 +    SDL_hapticlist_tail = NULL;
     1.9  }
    1.10  
    1.11