diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2015-05-15 12:36:04 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2015-05-19 15:27:29 +0100 |
commit | c99ce18efb8c21e6af3b2b2625abacc586ab2a65 (patch) | |
tree | 1ac4d3024693eb74e1db57873f7986406e0f56bb /clutter/clutter-actor.c | |
parent | e72a1a44e6e339c55acecba67e2f99412982b832 (diff) | |
download | clutter-c99ce18efb8c21e6af3b2b2625abacc586ab2a65.tar.gz |
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
Diffstat (limited to 'clutter/clutter-actor.c')
-rw-r--r-- | 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 cffc61b83..0305b748e 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); } |