changeset 3089:0ea7b6bb4054

Fixed potential double-free crash
author Sam Lantinga <slouken@libsdl.org>
date Fri, 06 Mar 2009 05:53:33 +0000
parents 1825768f1f72
children 37f9304df6a9
files src/joystick/linux/SDL_sysjoystick.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
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 */