bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=046c5cd58e1feb8760a1fbf4a1bb4253ed40f947

commit 046c5cd58e1feb8760a1fbf4a1bb4253ed40f947
Author: Marcel Hollerbach <m...@marcel-hollerbach.de>
Date:   Mon Mar 15 14:01:32 2021 +0100

    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.
---
 src/lib/eeze/eeze_udev_walk.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/lib/eeze/eeze_udev_walk.c b/src/lib/eeze/eeze_udev_walk.c
index 4cd661b184..5df34178a8 100644
--- a/src/lib/eeze/eeze_udev_walk.c
+++ b/src/lib/eeze/eeze_udev_walk.c
@@ -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);
 }

-- 


Reply via email to