mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 12:55:37 +00:00
Fixed bug 4005 - Android, SDL_IsGameController() crashes is index is out of range
Sylvain On Android, if you give an invalid index to SDL_IsGameController(), it will crash in SDL_SYS_IsDPAD_DeviceIndex().
This commit is contained in:
parent
e5cfa24182
commit
fee2469c65
|
@ -911,6 +911,13 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
||||||
ControllerMapping_t *mapping;
|
ControllerMapping_t *mapping;
|
||||||
|
|
||||||
SDL_LockJoysticks();
|
SDL_LockJoysticks();
|
||||||
|
|
||||||
|
if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
|
||||||
|
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
|
||||||
|
SDL_UnlockJoysticks();
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
name = SDL_JoystickNameForIndex(device_index);
|
name = SDL_JoystickNameForIndex(device_index);
|
||||||
guid = SDL_JoystickGetDeviceGUID(device_index);
|
guid = SDL_JoystickGetDeviceGUID(device_index);
|
||||||
mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid);
|
mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid);
|
||||||
|
@ -1353,13 +1360,14 @@ SDL_GameControllerOpen(int device_index)
|
||||||
SDL_GameController *gamecontrollerlist;
|
SDL_GameController *gamecontrollerlist;
|
||||||
ControllerMapping_t *pSupportedController = NULL;
|
ControllerMapping_t *pSupportedController = NULL;
|
||||||
|
|
||||||
|
SDL_LockJoysticks();
|
||||||
|
|
||||||
if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
|
if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
|
||||||
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
|
SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
|
||||||
|
SDL_UnlockJoysticks();
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockJoysticks();
|
|
||||||
|
|
||||||
gamecontrollerlist = SDL_gamecontrollers;
|
gamecontrollerlist = SDL_gamecontrollers;
|
||||||
/* If the controller is already open, return it */
|
/* If the controller is already open, return it */
|
||||||
while (gamecontrollerlist) {
|
while (gamecontrollerlist) {
|
||||||
|
|
Loading…
Reference in a new issue