aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-06-24 15:18:00 +0200
committerSimon Ser <contact@emersion.fr>2020-06-25 10:33:58 +0200
commitb937c7b05e507b861499965434d09cf526d83cde (patch)
tree2b00e7466d54117e98f6f72eec17991cae6046b0
parent4a4da256ddce84c6ddf4574645f8f88c66940c8c (diff)
layer-shell: handle serial wrapping overflow
-rw-r--r--types/wlr_layer_shell_v1.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c
index 32e8b0bb..9611ed7f 100644
--- a/types/wlr_layer_shell_v1.c
+++ b/types/wlr_layer_shell_v1.c
@@ -58,20 +58,17 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
struct wl_resource *resource, uint32_t serial) {
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource);
- bool found = false;
- struct wlr_layer_surface_v1_configure *configure, *tmp;
-
if (!surface || surface->closed) {
return;
}
- wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
- if (configure->serial < serial) {
- layer_surface_configure_destroy(configure);
- } else if (configure->serial == serial) {
+
+ // First find the ack'ed configure
+ bool found = false;
+ struct wlr_layer_surface_v1_configure *configure, *tmp;
+ wl_list_for_each(configure, &surface->configure_list, link) {
+ if (configure->serial == serial) {
found = true;
break;
- } else {
- break;
}
}
if (!found) {
@@ -80,6 +77,13 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
"wrong configure serial: %u", serial);
return;
}
+ // Then remove old configures from the list
+ wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
+ if (configure->serial == serial) {
+ break;
+ }
+ layer_surface_configure_destroy(configure);
+ }
if (surface->acked_configure) {
layer_surface_configure_destroy(surface->acked_configure);