diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2018-02-05 00:59:07 +0100 |
|---|---|---|
| committer | Léo Lam <leo@innovatetechnologi.es> | 2018-02-05 01:01:05 +0100 |
| commit | 6a93223283bd0d2bef8ce9c29f5043ade49a6831 (patch) | |
| tree | f87071ea47d830fe9e75157e739e3fb9902ae805 /Source/Core/InputCommon/ControllerInterface/evdev | |
| parent | 0822bb347d12c97cb9bb307f624d6f8a8ed1cf06 (diff) | |
evdev: Always unref received udev devices
Whenever udev_monitor_receive_device() returns a non-null pointer,
the device must be unref'd after use with udev_device_unref().
We previously missed some unref calls for non-evdev devices.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/evdev')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 6e4aab495d..2049c85237 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -76,10 +76,11 @@ static void HotplugThreadFunc() if (ret < 1 || !FD_ISSET(monitor_fd, &fds)) continue; - udev_device* dev = udev_monitor_receive_device(monitor); + std::unique_ptr<udev_device, decltype(&udev_device_unref)> dev{ + udev_monitor_receive_device(monitor), udev_device_unref}; - const char* action = udev_device_get_action(dev); - const char* devnode = udev_device_get_devnode(dev); + const char* action = udev_device_get_action(dev.get()); + const char* devnode = udev_device_get_devnode(dev.get()); if (!devnode) continue; @@ -107,7 +108,6 @@ static void HotplugThreadFunc() s_devnode_name_map.insert(std::pair<std::string, std::string>(devnode, name)); } } - udev_device_unref(dev); } NOTICE_LOG(SERIALINTERFACE, "evdev hotplug thread stopped"); } |
