use more safety list_for_each_safe when remove element in traversing list

Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
This commit is contained in:
weizhixiang 2021-05-19 21:48:34 +09:00 committed by Peter Hutterer
parent cce5921015
commit 1339dbaf3d
3 changed files with 3 additions and 3 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;