Fixed potential double-free crash
authorSam Lantinga <slouken@libsdl.org>
Fri, 06 Mar 2009 05:53:33 +0000
changeset 3089 0ea7b6bb4054
parent 3088 1825768f1f72
child 3090 37f9304df6a9
Fixed potential double-free crash
src/joystick/linux/SDL_sysjoystick.c
--- 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 */