diff src/joystick/linux/SDL_sysjoystick.c @ 3089:0ea7b6bb4054

Fixed potential double-free crash
author Sam Lantinga <slouken@libsdl.org>
date Fri, 06 Mar 2009 05:53:33 +0000
parents cfc8b35ad6b1
children 09172593e9b6
line wrap: on
line diff
--- a/src/joystick/linux/SDL_sysjoystick.c	Fri Mar 06 05:48:52 2009 +0000
+++ b/src/joystick/linux/SDL_sysjoystick.c	Fri Mar 06 05:53:33 2009 +0000
@@ -1210,9 +1210,11 @@
     int i;
 
     for (i = 0; SDL_joylist[i].fname; ++i) {
-        SDL_free(SDL_joylist[i].fname);
+        if (SDL_joylist[i].fname) {
+            SDL_free(SDL_joylist[i].fname);
+            SDL_joylist[i].fname = NULL;
+        }
     }
-    SDL_joylist[0].fname = NULL;
 }
 
 #endif /* SDL_JOYSTICK_LINUX */