traps: Clip the trapezoid extents against the clip extents

Just in case the clip polygon turns out to be much larger than the
operation extents (silly us for not reducing it correctly) and lead to
catastrophe, such as:

Program received signal SIGSEGV, Segmentation fault.
pixman_fill_sse2 (bits=<optimized out>, stride=4, bpp=8, x=0, y=0,
width=3, height=-34811, data=0) at pixman-sse2.c:3369
3369		    *(uint16_t *)d = data;

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-04-08 17:58:13 +01:00
parent 6f28f0b33c
commit 113ec6bf0c

View file

@ -218,8 +218,13 @@ combine_clip_as_traps (const cairo_traps_compositor_t *compositor,
_cairo_traps_fini (&traps);
cairo_surface_destroy (src);
if (status == CAIRO_INT_STATUS_SUCCESS &&
(fixup.width < extents->width || fixup.height < extents->height)) {
if (unlikely (status))
return status;
if (! _cairo_rectangle_intersect (&fixup, extents))
return CAIRO_STATUS_SUCCESS;
if (fixup.width < extents->width || fixup.height < extents->height) {
cairo_boxes_t clear;
_cairo_boxes_init (&clear);