From 3c3f3b1cc3c30c646795668662c3234656135cd2 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 16 Oct 2019 16:02:59 -0400 Subject: [PATCH] libweston: Fix integer underflow in weston_layer_mask_is_infinite ubsan doesn't like what we were doing here: ../libweston/compositor.c:3021:21: runtime error: signed integer overflow: -2147483648 + -1 cannot be represented in type 'int' Rather than try to be clever in invoking weston_layer_set_mask, just build the maximal mask explicitly. --- libweston/compositor.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index 63f3880c..88ca7383 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -3030,8 +3030,16 @@ weston_layer_set_mask(struct weston_layer *layer, WL_EXPORT void weston_layer_set_mask_infinite(struct weston_layer *layer) { - weston_layer_set_mask(layer, INT32_MIN, INT32_MIN, - UINT32_MAX, UINT32_MAX); + struct weston_view *view; + + layer->mask.x1 = INT32_MIN; + layer->mask.x2 = INT32_MAX; + layer->mask.y1 = INT32_MIN; + layer->mask.y2 = INT32_MAX; + + wl_list_for_each(view, &layer->view_list.link, layer_link.link) { + weston_view_geometry_dirty(view); + } } WL_EXPORT bool @@ -3039,8 +3047,8 @@ weston_layer_mask_is_infinite(struct weston_layer *layer) { return layer->mask.x1 == INT32_MIN && layer->mask.y1 == INT32_MIN && - layer->mask.x2 == INT32_MIN + UINT32_MAX && - layer->mask.y2 == INT32_MIN + UINT32_MAX; + layer->mask.x2 == INT32_MAX && + layer->mask.y2 == INT32_MAX; } /** @@ -7346,7 +7354,7 @@ weston_compositor_shutdown(struct weston_compositor *ec) * \ingroup compositor */ WL_EXPORT void -weston_compositor_exit_with_code(struct weston_compositor *compositor, +weston_compositor_exit_with_code(struct weston_compositor *compositor, int exit_code) { if (compositor->exit_code == EXIT_SUCCESS)