Post protocol error on invalid wl_surface scale

Letting the scale be set to 0 causes division by zero errors.
This commit is contained in:
Sebastian Krzyszkowiak 2019-02-15 00:38:33 +01:00 committed by emersion
parent bc048b22fb
commit 69b9e2ae8f

View file

@ -459,6 +459,11 @@ static void surface_set_buffer_transform(struct wl_client *client,
static void surface_set_buffer_scale(struct wl_client *client, static void surface_set_buffer_scale(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
int32_t scale) { int32_t scale) {
if (scale <= 0) {
wl_resource_post_error(resource, WL_SURFACE_ERROR_INVALID_SCALE,
"Specified scale value (%d) is not positive", scale);
return;
}
struct wlr_surface *surface = wlr_surface_from_resource(resource); struct wlr_surface *surface = wlr_surface_from_resource(resource);
surface->pending.committed |= WLR_SURFACE_STATE_SCALE; surface->pending.committed |= WLR_SURFACE_STATE_SCALE;
surface->pending.scale = scale; surface->pending.scale = scale;