[Pixman] [PATCH 2/2] _intersect_rect should return an empty region when intersecting with an empty rect
Bill McCloskey
wmccloskey at mozilla.com
Tue Feb 2 17:36:10 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.
Reviewed-by: Siarhei Siamashka <siarhei.siamashka at gmail.com>
---
pixman/pixman-region.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index 59bc9c7..69466ed 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -1329,16 +1329,33 @@ 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);
+ if (PIXREGION_NAR (source))
+ {
+ dest->data = pixman_broken_data;
+ return FALSE;
+ }
+ else
+ {
+ 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/20160202/e8b3cd01/attachment.html>
More information about the Pixman
mailing list