evdev: plug a potential memleak
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 7 Aug 2013 01:04:47 +0000 (11:04 +1000)
committerJonas Ådahl <jadahl@gmail.com>
Sun, 10 Nov 2013 16:51:32 +0000 (17:51 +0100)
For touchpads, device->dispatch is set up when exiting
evdev_handle_device() and a potential source for a memleak.
This can't actually happen at the moment, as evdev_handle_device() won't
fail for touchpads after setting up the dispatch but prevent this from
happening in the future.

src/evdev.c

index 24f52ca..f3483c6 100644 (file)
@@ -593,6 +593,8 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
        device->devname = strdup(devname);
 
        if (!evdev_handle_device(device)) {
+               if (device->dispatch)
+                       device->dispatch->interface->destroy(dispatch);
                if (device->mtdev)
                        mtdev_close_delete(device->mtdev);
                free(device->devnode);