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.
dev
Adam Jackson 5 years ago
parent 267b16e8f4
commit 3c3f3b1cc3
  1. 16
      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;
}
/**

Loading…
Cancel
Save