From b15bbd4e3f382643491e60b4ec2ad6a1d54db4ad Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Thu, 22 Apr 2021 16:11:13 -0700 Subject: [PATCH] SDL_udev: check for NULL return value from udev_device_get_action Signed-off-by: Steven Noonan Signed-off-by: Sam Lantinga --- src/core/linux/SDL_udev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index 08f4a4b2c..8eaf2f204 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -449,13 +449,15 @@ SDL_UDEV_Poll(void) } action = _this->syms.udev_device_get_action(dev); - if (SDL_strcmp(action, "add") == 0) { - /* Wait for the device to finish initialization */ - SDL_Delay(100); + if (action) { + if (SDL_strcmp(action, "add") == 0) { + /* Wait for the device to finish initialization */ + SDL_Delay(100); - device_event(SDL_UDEV_DEVICEADDED, dev); - } else if (SDL_strcmp(action, "remove") == 0) { - device_event(SDL_UDEV_DEVICEREMOVED, dev); + device_event(SDL_UDEV_DEVICEADDED, dev); + } else if (SDL_strcmp(action, "remove") == 0) { + device_event(SDL_UDEV_DEVICEREMOVED, dev); + } } _this->syms.udev_device_unref(dev);