aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Krzyszkowiak <dos@dosowisko.net>2019-02-15 00:38:33 +0100
committeremersion <contact@emersion.fr>2019-02-15 00:45:12 +0100
commit69b9e2ae8fd6ae01cf57115409960ff08cae96ad (patch)
tree4d891b5012769cb99484028a531a8510a15dad58
parentbc048b22fb3158e9ecad3e8e32d63e0e03eaa7bb (diff)
Post protocol error on invalid wl_surface scale
Letting the scale be set to 0 causes division by zero errors.
-rw-r--r--types/wlr_surface.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 27176ef0..148b434d 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -459,6 +459,11 @@ static void surface_set_buffer_transform(struct wl_client *client,
static void surface_set_buffer_scale(struct wl_client *client,
struct wl_resource *resource,
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);
surface->pending.committed |= WLR_SURFACE_STATE_SCALE;
surface->pending.scale = scale;