xdg-shell: handle serial wrapping overflow

This commit is contained in:
Isaac Freund 2020-06-24 15:19:05 +02:00 committed by Simon Ser
parent b937c7b05e
commit 86e20f48c6
2 changed files with 21 additions and 13 deletions

View File

@ -107,17 +107,13 @@ static void xdg_surface_handle_ack_configure(struct wl_client *client,
return;
}
// First find the ack'ed configure
bool found = false;
struct wlr_xdg_surface_configure *configure, *tmp;
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
if (configure->serial < serial) {
wlr_signal_emit_safe(&surface->events.ack_configure, configure);
xdg_surface_configure_destroy(configure);
} else if (configure->serial == serial) {
wl_list_for_each(configure, &surface->configure_list, link) {
if (configure->serial == serial) {
found = true;
break;
} else {
break;
}
}
if (!found) {
@ -126,6 +122,14 @@ static void xdg_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;
}
wlr_signal_emit_safe(&surface->events.ack_configure, configure);
xdg_surface_configure_destroy(configure);
}
switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_NONE:

View File

@ -156,16 +156,13 @@ static void xdg_surface_handle_ack_configure(struct wl_client *client,
return;
}
// First find the ack'ed configure
bool found = false;
struct wlr_xdg_surface_v6_configure *configure, *tmp;
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
if (configure->serial < serial) {
xdg_surface_configure_destroy(configure);
} else if (configure->serial == serial) {
wl_list_for_each(configure, &surface->configure_list, link) {
if (configure->serial == serial) {
found = true;
break;
} else {
break;
}
}
if (!found) {
@ -174,6 +171,13 @@ static void xdg_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;
}
xdg_surface_configure_destroy(configure);
}
switch (surface->role) {
case WLR_XDG_SURFACE_V6_ROLE_NONE: