eeze_scanner: do not crash

the free logic here was wrong. The udev_device_get_parent results get
automatically unrefed when the original device is deleted.

This caused random segfaults when starting e.
This commit is contained in:
Marcel Hollerbach 2021-03-15 14:01:32 +01:00
parent 3cd6191409
commit 046c5cd58e
1 changed files with 6 additions and 12 deletions

View File

@ -40,7 +40,7 @@ EAPI const char *
eeze_udev_walk_get_sysattr(const char *syspath,
const char *sysattr)
{
_udev_device *device, *child, *parent;
_udev_device *device, *parent;
const char *test = NULL;
if (!syspath)
@ -49,18 +49,12 @@ eeze_udev_walk_get_sysattr(const char *syspath,
if (!(device = _new_device(syspath)))
return NULL;
for (parent = device; parent;)
for (parent = device; parent && !test;)
{
if ((test = udev_device_get_sysattr_value(parent, sysattr)))
{
test = eina_stringshare_add(test);
udev_device_unref(parent);
return test;
}
child = parent;
parent = udev_device_get_parent(child);
udev_device_unref(child);
test = udev_device_get_sysattr_value(parent, sysattr);
parent = udev_device_get_parent(parent);
}
return NULL;
udev_device_unref(device);
return eina_stringshare_add(test);
}