Fix a crash when initializing an illuminance sensor on Linux (#17408)

This commit is contained in:
Jesse Talavera 2025-01-13 15:54:52 -05:00 committed by GitHub
parent 47d888364d
commit 0bb0077358
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -201,6 +201,10 @@ linux_illuminance_sensor_t *linux_open_illuminance_sensor(unsigned rate)
if (!sensor)
goto error;
device = retro_opendir(IIO_DEVICES_DIR);
if (!device)
goto error;
sensor->millilux = 0;
sensor->poll_rate = rate ? rate : DEFAULT_POLL_RATE;
sensor->thread = NULL; /* We'll spawn a thread later, once we find a sensor */
@ -243,7 +247,7 @@ linux_illuminance_sensor_t *linux_open_illuminance_sensor(unsigned rate)
}
error:
RARCH_ERR("Failed to find an illuminance sensor\n");
RARCH_ERR("Failed to find an illuminance sensor in " IIO_DEVICES_DIR "\n");
retro_closedir(device);
free(sensor);