Skip to content

Commit

Permalink
tools: list-devices: unref the udev device
Browse files Browse the repository at this point in the history
Fixes a memory leak that prevents us from running list-devices in valgrind.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Jun 20, 2018
1 parent 7c51c88 commit 1605f71
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/libinput-list-devices.c
Expand Up @@ -270,6 +270,7 @@ print_device_notify(struct libinput_event *ev)
struct libinput_device *dev = libinput_event_get_device(ev);
struct libinput_seat *seat = libinput_device_get_seat(dev);
struct libinput_device_group *group;
struct udev_device *udev_device;
double w, h;
static int next_group_id = 0;
intptr_t group_id;
Expand All @@ -283,8 +284,8 @@ print_device_notify(struct libinput_event *ev)
libinput_device_group_set_user_data(group, (void*)group_id);
}

devnode = udev_device_get_devnode(
libinput_device_get_udev_device(dev));
udev_device = libinput_device_get_udev_device(dev);
devnode = udev_device_get_devnode(udev_device);

printf("Device: %s\n"
"Kernel: %s\n"
Expand All @@ -296,6 +297,8 @@ print_device_notify(struct libinput_event *ev)
libinput_seat_get_physical_name(seat),
libinput_seat_get_logical_name(seat));

udev_device_unref(udev_device);

if (libinput_device_get_size(dev, &w, &h) == 0)
printf("Size: %.fx%.fmm\n", w, h);
printf("Capabilities: ");
Expand Down

0 comments on commit 1605f71

Please sign in to comment.