From ab17c98c947aa9a53eecf27d7242c18c5dccbbfc Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Thu, 30 Dec 2021 03:41:07 +0100 Subject: [PATCH] wayland/surface: Implement WL_SURFACE_ERROR_INVALID_SIZE check From the spec: > This means that at commit time the supplied buffer size must be > an integer multiple of the buffer_scale. If that's not the case, > an invalid_size error is sent. Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1938 Part-of: --- src/wayland/meta-wayland-surface.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 5bd0d684d..1032c4a78 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -787,6 +787,17 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface, if (state->scale > 0) surface->scale = state->scale; + if ((get_buffer_width (surface) % surface->scale != 0) || + (get_buffer_height (surface) % surface->scale != 0)) + { + wl_resource_post_error (surface->resource, WL_SURFACE_ERROR_INVALID_SIZE, + "Buffer size (%dx%d) must be an integer multiple " + "of the buffer_scale (%d)", + get_buffer_width (surface), + get_buffer_height (surface), surface->scale); + goto cleanup; + } + if (state->has_new_buffer_transform) surface->buffer_transform = state->buffer_transform;