[PATCH weston] compositor: raise errors when bad scale or transform values are used

Jonny Lamb jonny.lamb at collabora.co.uk
Thu Nov 21 08:44:32 PST 2013


---
 src/compositor.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index c14ec1f..f14b487 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2063,6 +2063,16 @@ surface_set_buffer_transform(struct wl_client *client,
 {
 	struct weston_surface *surface = wl_resource_get_user_data(resource);
 
+	/* if wl_output.transform grows more members this will need to be updated. */
+	if (transform < 0 ||
+	    transform > WL_OUTPUT_TRANSFORM_FLIPPED_270) {
+		wl_resource_post_error(resource,
+			WL_SURFACE_ERROR_INVALID_TRANSFORM,
+			"buffer transform must be a valid transform "
+			"('%d' specified)", transform);
+		return;
+	}
+
 	surface->pending.buffer_transform = transform;
 }
 
@@ -2073,6 +2083,14 @@ surface_set_buffer_scale(struct wl_client *client,
 {
 	struct weston_surface *surface = wl_resource_get_user_data(resource);
 
+	if (scale < 1) {
+		wl_resource_post_error(resource,
+			WL_SURFACE_ERROR_INVALID_SCALE,
+			"buffer scale must be at least one "
+			"('%d' specified)", scale);
+		return;
+	}
+
 	surface->pending.buffer_scale = scale;
 }
 
-- 
1.8.4.2



More information about the wayland-devel mailing list