Fixed potential double-free crash
authorSam Lantinga <slouken@libsdl.org>
Fri, 06 Mar 2009 05:53:33 +0000
changeset 30890ea7b6bb4054
parent 3088 1825768f1f72
child 3090 37f9304df6a9
Fixed potential double-free crash
src/joystick/linux/SDL_sysjoystick.c
     1.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Fri Mar 06 05:48:52 2009 +0000
     1.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Fri Mar 06 05:53:33 2009 +0000
     1.3 @@ -1210,9 +1210,11 @@
     1.4      int i;
     1.5  
     1.6      for (i = 0; SDL_joylist[i].fname; ++i) {
     1.7 -        SDL_free(SDL_joylist[i].fname);
     1.8 +        if (SDL_joylist[i].fname) {
     1.9 +            SDL_free(SDL_joylist[i].fname);
    1.10 +            SDL_joylist[i].fname = NULL;
    1.11 +        }
    1.12      }
    1.13 -    SDL_joylist[0].fname = NULL;
    1.14  }
    1.15  
    1.16  #endif /* SDL_JOYSTICK_LINUX */