[Pixman] [PATCH] _intersect_rect should return an empty region when intersecting with an empty rect
Bill McCloskey
wmccloskey at mozilla.com
Wed Jan 13 13:43:39 PST 2016
When you call _intersect_rect and pass it an empty rectangle,
it creates an invalid region from that rectangle. The only valid
empty region is the one where the data pointer points to
pixman_region_empty_data. The region created by _intersect_rect has
a null data pointer, and so _not_empty returns true for it even if
the extents are empty.
This patch uses code similar to what's in _union_rect to handle empty
rectangles.
---
pixman/pixman-region.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index 59bc9c7..95911db 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -1329,16 +1329,25 @@ PREFIX(_intersect_rect) (region_type_t *dest,
region_type_t region;
region.data = NULL;
region.extents.x1 = x;
region.extents.y1 = y;
region.extents.x2 = x + width;
region.extents.y2 = y + height;
+ if (!GOOD_RECT (®ion.extents))
+ {
+ if (BAD_RECT (®ion.extents))
+ _pixman_log_error (FUNC, "Invalid rectangle passed");
+ FREE_DATA (dest);
+ PREFIX (_init) (dest);
+ return TRUE;
+ }
+
return PREFIX(_intersect) (dest, source, ®ion);
}
/* Convenience function for performing union of region with a
* single rectangle
*/
*/
PIXMAN_EXPORT pixman_bool_t
PREFIX (_union_rect) (region_type_t *dest,
--
2.7.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pixman/attachments/20160113/e3fd0cb9/attachment.html>
More information about the Pixman
mailing list