SDL_udev: check for NULL return value from udev_device_get_action

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
This commit is contained in:
Steven Noonan 2021-04-22 16:11:13 -07:00 committed by Sam Lantinga
parent cf05a5eb0c
commit b15bbd4e3f
1 changed files with 8 additions and 6 deletions

View File

@ -449,13 +449,15 @@ SDL_UDEV_Poll(void)
} }
action = _this->syms.udev_device_get_action(dev); action = _this->syms.udev_device_get_action(dev);
if (SDL_strcmp(action, "add") == 0) { if (action) {
/* Wait for the device to finish initialization */ if (SDL_strcmp(action, "add") == 0) {
SDL_Delay(100); /* Wait for the device to finish initialization */
SDL_Delay(100);
device_event(SDL_UDEV_DEVICEADDED, dev); device_event(SDL_UDEV_DEVICEADDED, dev);
} else if (SDL_strcmp(action, "remove") == 0) { } else if (SDL_strcmp(action, "remove") == 0) {
device_event(SDL_UDEV_DEVICEREMOVED, dev); device_event(SDL_UDEV_DEVICEREMOVED, dev);
}
} }
_this->syms.udev_device_unref(dev); _this->syms.udev_device_unref(dev);