Merge pull request #1395 from reicast/baka/evdev_crash2

evdev: If there was an error initializing a controller, don't proceed
This commit is contained in:
Christoph 2018-09-20 18:46:12 +02:00 committed by GitHub
commit 4000b88771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -469,18 +469,26 @@
const char* mapping = (cfgExists("input", evdev_config_key) == 2 ? (tmp = cfgLoadStr("input", evdev_config_key, "")).c_str() : NULL);
free(evdev_config_key);
input_evdev_init(&evdev_controllers[port], evdev_device, mapping);
int err = input_evdev_init(&evdev_controllers[port], evdev_device, mapping);
free(evdev_device);
// If there was an error initializing the controller, don't proceed any further
if (err == 0)
{
for (i = 0; i < port; i++)
{
// If the controller could not be loaded, skip this one as it can't interfere
if (evdev_controllers[i].fd < 0)
continue;
if (evdev_device_id[port] == evdev_device_id[i])
{
// Multiple controllers with the same device, check for multiple button assignments
if (input_evdev_button_duplicate_button(evdev_controllers[i].mapping, evdev_controllers[port].mapping))
{
printf("WARNING: One or more button(s) of this device is also used in the configuration of input device %d (mapping: %s)\n", i, evdev_controllers[i].mapping->name.c_str());
printf("WARNING: One or more button(s) of this device is also used in the configuration of input device %d (mapping: %s)\n", i,
evdev_controllers[i].mapping->name.c_str());
}
}
}
@ -489,6 +497,7 @@
}
}
}
}
void input_evdev_close()
{