libinput: allow evdev_device_set_output(dev, NULL)
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Thu, 20 Apr 2017 08:38:06 +0000 (11:38 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Fri, 20 Apr 2018 12:27:54 +0000 (15:27 +0300)
commit98d50cc3112dcd6e32118bdc7adc266773ace1cc
tree9d55c34e2fd9f422976de93136fb73e0ff6f54a7
parent018e6ade21592bfad9d544408ccfe58134b865e4
libinput: allow evdev_device_set_output(dev, NULL)

Removing the output association from an evdev_device is more than just
setting the pointer to NULL, one also needs to remove the destroy
listener and flag the destroy listener as unused (notify == NULL).

evdev_device_set_output() can already remove associations, so let it
also handle an assignment to NULL output.

Fix notify_output_destroy() to handle removing an association correctly.
Previously, the listener was left "used", which would mean the next call
to evdev_device_set_output() would have wl_list_remove()'d, accessing
freed memory. This could be triggered by having a touchscreen with a
specified output association, and unplugging then re-plugging the
corresponding output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
libweston/libinput-device.c