[clutter] actor: Guard against negative-sized allocations



commit c99ce18efb8c21e6af3b2b2625abacc586ab2a65
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri May 15 12:36:04 2015 +0100

    actor: Guard against negative-sized allocations
    
    The allocate_align_fill() method may end up trying to allocate an actor
    with a negative size, due to rounding and floating point operations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749420

 clutter/clutter-actor.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index cffc61b..0305b74 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -15564,15 +15564,18 @@ clutter_actor_allocate_align_fill (ClutterActor           *self,
   clutter_actor_box_get_origin (box, &x_offset, &y_offset);
   clutter_actor_box_get_size (box, &available_width, &available_height);
 
-  if (available_width < 0)
-    available_width = 0;
+  if (available_width <= 0)
+    available_width = 0.f;
 
-  if (available_height < 0)
-    available_height = 0;
+  if (available_height <= 0)
+    available_height = 0.f;
 
   allocation.x1 = x_offset;
   allocation.y1 = y_offset;
 
+  if (available_width == 0.f && available_height == 0.f)
+    goto out;
+
   if (x_fill)
     child_width = available_width;
 
@@ -15656,8 +15659,8 @@ out:
 
   allocation.x1 = floorf (allocation.x1);
   allocation.y1 = floorf (allocation.y1);
-  allocation.x2 = ceilf (allocation.x1 + child_width);
-  allocation.y2 = ceilf (allocation.y1 + child_height);
+  allocation.x2 = ceilf (allocation.x1 + MAX (child_width, 0));
+  allocation.y2 = ceilf (allocation.y1 + MAX (child_height, 0));
 
   clutter_actor_allocate (self, &allocation, flags);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]