From f8b75b1a14bd3e3b9279b10711e6b7dfac3d235b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 21 Jun 2014 20:40:00 -0700 Subject: [PATCH] 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 281a9316b..7598a5633 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -624,6 +624,8 @@ SDL_SYS_HapticQuit(void) #endif /* SDL_USE_LIBUDEV */ numhaptics = 0; + SDL_hapticlist = NULL; + SDL_hapticlist_tail = NULL; }