From 9f03a09e4083c1fa636291f5e90496b7c2ea29c1 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 14 Sep 2015 14:39:07 +0200 Subject: [PATCH] Use REGION_INTERSECT() rather than trying to compute things manually REGION_INIT() does not handle an empty or invalid BoxRec, so this method makes sure we don't feed bad rects further in to the process. --- unix/xserver/hw/vnc/vncHooks.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/unix/xserver/hw/vnc/vncHooks.c b/unix/xserver/hw/vnc/vncHooks.c index 9ab6febc..58a0eca8 100644 --- a/unix/xserver/hw/vnc/vncHooks.c +++ b/unix/xserver/hw/vnc/vncHooks.c @@ -728,13 +728,23 @@ static void vncHooksComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, if (pDst->pDrawable->type == DRAWABLE_WINDOW && ((WindowPtr) pDst->pDrawable)->viewable) { BoxRec box; + RegionRec fbreg; box.x1 = max(pDst->pDrawable->x + xDst, 0); box.y1 = max(pDst->pDrawable->y + yDst, 0); - box.x2 = min(box.x1 + width, pScreen->width); - box.y2 = min(box.y1 + height, pScreen->height); - + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; REGION_INIT(pScreen, &changed, &box, 0); + + box.x1 = 0; + box.y1 = 0; + box.x2 = pScreen->width; + box.y2 = pScreen->height; + REGION_INIT(pScreen, &fbreg, &box, 0); + + REGION_INTERSECT(pScreen, &changed, &changed, &fbreg); + + REGION_UNINIT(pScreen, &fbreg); } else { REGION_NULL(pScreen, &changed); } -- 2.39.5