barrier: Complain loudly if bogus barriers are created

The API allows for invalid barriers to be created; in an X11 session,
this could result in involutary early exit, so guard against those with
soft asserts. These will be logged in the journal as warnings, but will
avoid the crash unless compiled out.

Note that this doesn't fix the bug, it just makes it more detectable.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1901610
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1611>
This commit is contained in:
Jonas Ådahl 2020-11-27 15:41:17 +01:00
parent 8b6ea12fac
commit f5949af0bb

View File

@ -180,6 +180,10 @@ meta_barrier_constructed (GObject *object)
g_return_if_fail (priv->border.line.a.x == priv->border.line.b.x || g_return_if_fail (priv->border.line.a.x == priv->border.line.b.x ||
priv->border.line.a.y == priv->border.line.b.y); priv->border.line.a.y == priv->border.line.b.y);
g_return_if_fail (priv->border.line.a.x >= 0);
g_return_if_fail (priv->border.line.a.y >= 0);
g_return_if_fail (priv->border.line.b.x >= 0);
g_return_if_fail (priv->border.line.b.y >= 0);
#if defined(HAVE_NATIVE_BACKEND) #if defined(HAVE_NATIVE_BACKEND)
if (META_IS_BACKEND_NATIVE (meta_get_backend ())) if (META_IS_BACKEND_NATIVE (meta_get_backend ()))