diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2013-08-26 14:35:32 -0700 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-08-26 15:33:39 -0700 |
commit | 2471fac4d99b93b4557fa8fa1a417c37aba97f4a (patch) | |
tree | 5e3aeb20bf9f272aa16f19baef7937cda13f36b3 | |
parent | c2bc9223482288e884f8d4553004a86eccd569e3 (diff) | |
download | weston-2471fac4d99b93b4557fa8fa1a417c37aba97f4a.tar.gz weston-2471fac4d99b93b4557fa8fa1a417c37aba97f4a.tar.bz2 weston-2471fac4d99b93b4557fa8fa1a417c37aba97f4a.zip |
evdev: Initliaze device->link so we can wl_list_remove() without crashing
We were testing for wl_list_empty() on a { NULL, NULL } list (which
returns false) and then wl_list_remove()ing the device (which crashes).
-rw-r--r-- | src/evdev.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/evdev.c b/src/evdev.c index 3d225bcb..71399892 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -603,6 +603,7 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd) device->rel.dy = 0; device->dispatch = NULL; device->fd = device_fd; + wl_list_init(&device->link); ioctl(device->fd, EVIOCGNAME(sizeof(devname)), devname); devname[sizeof(devname) - 1] = '\0'; @@ -646,8 +647,7 @@ evdev_device_destroy(struct evdev_device *device) if (device->source) wl_event_source_remove(device->source); - if (!wl_list_empty(&device->link)) - wl_list_remove(&device->link); + wl_list_remove(&device->link); if (device->mtdev) mtdev_close_delete(device->mtdev); close(device->fd); |