Fixed crash trying to get the GUID of an invalid joystick index
authorSam Lantinga <slouken@libsdl.org>
Thu, 06 Jun 2013 18:20:06 -0700
changeset 72940923de98a63a
parent 7293 341d22fe9044
child 7295 737cc5bad795
Fixed crash trying to get the GUID of an invalid joystick index
src/joystick/SDL_joystick.c
     1.1 --- a/src/joystick/SDL_joystick.c	Thu Jun 06 17:59:01 2013 -0700
     1.2 +++ b/src/joystick/SDL_joystick.c	Thu Jun 06 18:20:06 2013 -0700
     1.3 @@ -729,6 +729,12 @@
     1.4  /* return the guid for this index */
     1.5  SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index)
     1.6  {
     1.7 +    if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
     1.8 +        SDL_JoystickGUID emptyGUID;
     1.9 +        SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
    1.10 +        SDL_zero( emptyGUID );
    1.11 +        return emptyGUID;
    1.12 +    }
    1.13      return SDL_SYS_JoystickGetDeviceGUID( device_index );
    1.14  }
    1.15