mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-31 14:29:14 +08:00
Fix assertion in LINUX_JoystickSetSensorsEnabled()
Calling LINUX_JoystickSetSensorsEnabled() after the joystick is unplugged will trigger this assertion.
This commit is contained in:
committed by
Sam Lantinga
parent
4e59bf6cb9
commit
f30392da5b
@@ -1565,7 +1565,9 @@ static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enab
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
SDL_assert(joystick->hwdata->item_sensor);
|
if (joystick->hwdata->item_sensor == NULL) {
|
||||||
|
return SDL_SetError("Sensors unplugged.");
|
||||||
|
}
|
||||||
joystick->hwdata->fd_sensor = open(joystick->hwdata->item_sensor->path, O_RDONLY | O_CLOEXEC, 0);
|
joystick->hwdata->fd_sensor = open(joystick->hwdata->item_sensor->path, O_RDONLY | O_CLOEXEC, 0);
|
||||||
if (joystick->hwdata->fd_sensor < 0) {
|
if (joystick->hwdata->fd_sensor < 0) {
|
||||||
return SDL_SetError("Couldn't open sensor file %s.", joystick->hwdata->item_sensor->path);
|
return SDL_SetError("Couldn't open sensor file %s.", joystick->hwdata->item_sensor->path);
|
||||||
|
|||||||
Reference in New Issue
Block a user