From 1339dbaf3da19ffbbe1602d0fee023faedcb6981 Mon Sep 17 00:00:00 2001 From: weizhixiang Date: Wed, 19 May 2021 21:48:34 +0900 Subject: [PATCH] use more safety list_for_each_safe when remove element in traversing list Signed-off-by: weizhixiang --- src/path-seat.c | 2 +- src/timer.c | 2 +- tools/libinput-debug-gui.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/path-seat.c b/src/path-seat.c index e0864314..ca60539b 100644 --- a/src/path-seat.c +++ b/src/path-seat.c @@ -414,7 +414,7 @@ libinput_path_remove_device(struct libinput_device *device) return; } - list_for_each(dev, &input->path_list, link) { + list_for_each_safe(dev, &input->path_list, link) { if (dev->udev_device == evdev->udev_device) { path_device_destroy(dev); break; diff --git a/src/timer.c b/src/timer.c index 9f90fdd5..22d7a962 100644 --- a/src/timer.c +++ b/src/timer.c @@ -136,7 +136,7 @@ libinput_timer_handler(struct libinput *libinput , uint64_t now) struct libinput_timer *timer; restart: - list_for_each(timer, &libinput->timer.list, link) { + list_for_each_safe(timer, &libinput->timer.list, link) { if (timer->expire == 0) continue; diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c index 187567a6..0cca8870 100644 --- a/tools/libinput-debug-gui.c +++ b/tools/libinput-debug-gui.c @@ -1016,7 +1016,7 @@ unregister_evdev_device(struct window *w, struct libinput_device *dev) { struct evdev_device *d; - list_for_each(d, &w->evdev_devices, node) { + list_for_each_safe(d, &w->evdev_devices, node) { if (d->libinput_device != dev) continue;