summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-09-01 17:02:44 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-09-01 17:02:44 +0100
commit407817ebb9129f1b946c7ba68e3e05d9540f478c (patch)
treea2701c97cc440195ee2ef9ce0d5c61b87bb70c51
parent92b37783eb2e9166efd82325f14d05de6a082081 (diff)
sna: Reject invalid CopyArea based on source clipping earlier
Given a ridiculous CopyArea, say copying from (-32000,-32000), the region extents will wrap around when translated before the final clip and reject test. To overcome this, do source based rejection earlier before the potential underflow. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_accel.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 68e2de6b..52c5a908 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -6880,6 +6880,14 @@ sna_do_copy(DrawablePtr src, DrawablePtr dst, GCPtr gc,
if (region.extents.y2 > src->y + (int) src->height)
region.extents.y2 = src->y + (int) src->height;
+ DBG(("%s: clipped src extents (%d, %d), (%d, %d)\n", __FUNCTION__,
+ region.extents.x1, region.extents.y1,
+ region.extents.x2, region.extents.y2));
+ if (box_empty(&region.extents)) {
+ DBG(("%s: src clipped out\n", __FUNCTION__));
+ return NULL;
+ }
+
/* Compute source clip region */
if (src->type == DRAWABLE_PIXMAP) {
if (src == dst && gc->clientClipType == CT_NONE) {
@@ -6921,10 +6929,12 @@ sna_do_copy(DrawablePtr src, DrawablePtr dst, GCPtr gc,
RegionTranslate(&region, dx-sx, dy-sy);
if (gc->pCompositeClip->data)
RegionIntersect(&region, &region, gc->pCompositeClip);
- DBG(("%s: copy region (%d, %d), (%d, %d) x %d\n", __FUNCTION__,
+ DBG(("%s: copy region (%d, %d), (%d, %d) x %d + (%d, %d)\n",
+ __FUNCTION__,
region.extents.x1, region.extents.y1,
region.extents.x2, region.extents.y2,
- region_num_rects(&region)));
+ region_num_rects(&region),
+ sx-dx, sy-dy));
if (!box_empty(&region.extents))
copy(src, dst, gc, &region, sx-dx, sy-dy, bitPlane, closure);