[Pixman] [PATCH 2/2] _intersect_rect should return an empty region when intersecting with an empty rect

Siarhei Siamashka siarhei.siamashka at gmail.com
Thu Feb 4 16:11:13 PST 2016


On Tue, 2 Feb 2016 17:36:10 -0800
Bill McCloskey <wmccloskey at mozilla.com> wrote:

> 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 (&region.extents))
> +    {
> +        if (BAD_RECT (&region.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, &region);
>  }
> 
>  /* Convenience function for performing union of region with a
>   * single rectangle
>   */
>  PIXMAN_EXPORT pixman_bool_t
>  PREFIX (_union_rect) (region_type_t *dest,

Thanks, everything looks good.

Only "Signed-off-by: Bill McCloskey <wmccloskey at mozilla.com>" is
missing.

Just like with the first patch, you can send a v2 variant of the
patch to the mailing list. Or I can push it to git with your
"Signed-off-by" added.

-- 
Best regards,
Siarhei Siamashka


More information about the Pixman mailing list