From 4135fafecd5c9a8daafb0caec96089cfa0926c6e Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 28 Feb 2019 18:58:02 +0100 Subject: [PATCH] seat: guard against button count corruption This is still a compositor bug, and bad events will be sent to clients. We'll need to track each button separately to handle this in wlroots. --- types/seat/wlr_seat_pointer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c index d03385cf..e473d9b3 100644 --- a/types/seat/wlr_seat_pointer.c +++ b/types/seat/wlr_seat_pointer.c @@ -346,7 +346,11 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat, } wlr_seat->pointer_state.button_count++; } else { - wlr_seat->pointer_state.button_count--; + if (wlr_seat->pointer_state.button_count == 0) { + wlr_log(WLR_ERROR, "Corrupted seat button count"); + } else { + wlr_seat->pointer_state.button_count--; + } } struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;