Merge branch 'udev-monitor-receive-device-returning-null'

Closes #109
This commit is contained in:
Daniel Eklöf 2021-10-01 16:45:22 +02:00
commit 804af178d5
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 13 additions and 3 deletions

View file

@ -25,6 +25,9 @@
* `left-margin` and `right-margin` from being rejected as invalid
options.
* Crash when `udev_monitor_receive_device()` returned `NULL`. This
affected the “backlight”, “battery” and “removables” modules
(https://codeberg.org/dnkl/yambar/issues/109).
### Security

View file

@ -189,9 +189,11 @@ run(struct module *mod)
break;
struct udev_device *dev = udev_monitor_receive_device(mon);
const char *sysname = udev_device_get_sysname(dev);
if (dev == NULL)
continue;
bool is_us = strcmp(sysname, m->device) == 0;
const char *sysname = udev_device_get_sysname(dev);
bool is_us = sysname != NULL && strcmp(sysname, m->device) == 0;
udev_device_unref(dev);
if (!is_us)

View file

@ -437,8 +437,10 @@ run(struct module *mod)
if (fds[1].revents & POLLIN) {
struct udev_device *dev = udev_monitor_receive_device(mon);
const char *sysname = udev_device_get_sysname(dev);
if (dev == NULL)
continue;
const char *sysname = udev_device_get_sysname(dev);
bool is_us = sysname != NULL && strcmp(sysname, m->battery) == 0;
udev_device_unref(dev);

View file

@ -571,6 +571,9 @@ run(struct module *mod)
if (fds[1].revents & POLLIN) {
struct udev_device *dev = udev_monitor_receive_device(dev_mon);
if (dev == NULL)
continue;
if (handle_udev_event(mod, dev))
update = true;
udev_device_unref(dev);