src/joystick/SDL_joystick.c
changeset 7294 0923de98a63a
parent 7279 f7805b13b485
child 7297 c43b23f0c000
--- a/src/joystick/SDL_joystick.c	Thu Jun 06 17:59:01 2013 -0700
+++ b/src/joystick/SDL_joystick.c	Thu Jun 06 18:20:06 2013 -0700
@@ -729,6 +729,12 @@
 /* return the guid for this index */
 SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index)
 {
+    if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
+        SDL_JoystickGUID emptyGUID;
+        SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
+        SDL_zero( emptyGUID );
+        return emptyGUID;
+    }
     return SDL_SYS_JoystickGetDeviceGUID( device_index );
 }