Skip to content

Commit

Permalink
Fixes 2356, [Android] SDL_JoystickGetAttached does not function
Browse files Browse the repository at this point in the history
Also fix a potential NULL pointer access in android/SDL_SYS_JoystickGetGUID
  • Loading branch information
gabomdq committed Jan 21, 2014
1 parent beee1c4 commit b131e74
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/joystick/android/SDL_sysjoystick.c
Expand Up @@ -284,6 +284,10 @@ Android_RemoveJoystick(int device_id)
}

const int retval = item->device_instance;
if (item->joystick) {
item->joystick->hwdata = NULL;
}

if (prev != NULL) {
prev->next = item->next;
} else {
Expand Down Expand Up @@ -507,7 +511,14 @@ SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )

SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
return ((SDL_joylist_item*)joystick->hwdata)->guid;
SDL_JoystickGUID guid;

if (joystick->hwdata != NULL) {
return ((SDL_joylist_item*)joystick->hwdata)->guid;
}

SDL_zero(guid);
return guid;
}

#endif /* SDL_JOYSTICK_ANDROID */
Expand Down

0 comments on commit b131e74

Please sign in to comment.