From 33c008b90aa0dcbe0154433cc6a6fe593e3956bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 30 May 2020 13:57:50 +0200 Subject: [PATCH] clutter/actor: Sanity check new allocations Apparently some shell extensions are setting invalid NaN allocations, leading to weird crashes like https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1849. Even though an implementation error like this probably deserves a crash, those can be hard to debug since the crash can happen anywhere the allocation is being used later. So let Clutter be the good guy and prevent implementations from setting invalid allocations by sanity-checking the ClutterActorBoxes using g_return_if_fail. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1849 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1280 --- clutter/clutter/clutter-actor.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 1cf09ac11..efcc004c4 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -2604,6 +2604,9 @@ clutter_actor_set_allocation_internal (ClutterActor *self, gboolean retval; ClutterActorBox old_alloc = { 0, }; + g_return_val_if_fail (!isnan (box->x1) && !isnan (box->x2) && + !isnan (box->y1) && !isnan (box->y2), FALSE); + obj = G_OBJECT (self); g_object_freeze_notify (obj); @@ -10366,6 +10369,11 @@ clutter_actor_allocate (ClutterActor *self, old_allocation = priv->allocation; real_allocation = *box; + g_return_if_fail (!isnan (real_allocation.x1) && + !isnan (real_allocation.x2) && + !isnan (real_allocation.y1) && + !isnan (real_allocation.y2)); + /* constraints are allowed to modify the allocation only here; we do * this prior to all the other checks so that we can bail out if the * allocation did not change