mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-19 09:48:14 +00:00
Fixed invalid read when SDL_GameControllerSetPlayerIndex() is passed a negative player_index
This commit is contained in:
@@ -186,7 +186,7 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
|
|||||||
SDL_joystick_players = new_players;
|
SDL_joystick_players = new_players;
|
||||||
SDL_memset(&SDL_joystick_players[SDL_joystick_player_count], 0xFF, (player_index - SDL_joystick_player_count + 1) * sizeof(SDL_joystick_players[0]));
|
SDL_memset(&SDL_joystick_players[SDL_joystick_player_count], 0xFF, (player_index - SDL_joystick_player_count + 1) * sizeof(SDL_joystick_players[0]));
|
||||||
SDL_joystick_player_count = player_index + 1;
|
SDL_joystick_player_count = player_index + 1;
|
||||||
} else if (SDL_joystick_players[player_index] == instance_id) {
|
} else if (player_index >= 0 && SDL_joystick_players[player_index] == instance_id) {
|
||||||
/* Joystick is already assigned the requested player index */
|
/* Joystick is already assigned the requested player index */
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user