diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2016-07-04 18:52:19 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2016-07-05 11:14:39 +1000 |
commit | b5ea4137244ec8f8e1cbd0f61e655dd114a45110 (patch) | |
tree | f27d49a2eb07053a905387a56a08a8a478705a2d | |
parent | 35a6ebc5369ec907a3745f61ef8a8e5b2ba6e065 (diff) |
test: fix a memleak when creating udev devices
If the first device we got didn't have the expected syspath we'd leak the
device and cause the valgrind tests to fail.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | test/litest.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/litest.c b/test/litest.c index 916677f6..9b4feed6 100644 --- a/test/litest.c +++ b/test/litest.c @@ -2340,7 +2340,7 @@ litest_create_uinput_device_from_description(const char *name, syspath = libevdev_uinput_get_syspath(uinput); /* blocking, we don't want to continue until udev is ready */ - do { + while (1) { udev_device = udev_monitor_receive_device(udev_monitor); litest_assert_notnull(udev_device); udev_action = udev_device_get_action(udev_device); @@ -2350,7 +2350,11 @@ litest_create_uinput_device_from_description(const char *name, } udev_syspath = udev_device_get_syspath(udev_device); - } while (!udev_syspath || strcmp(udev_syspath, syspath) != 0); + if (udev_syspath && streq(udev_syspath, syspath)) + break; + + udev_device_unref(udev_device); + } litest_assert(udev_device_get_property_value(udev_device, "ID_INPUT")); |