From db821a236ff90db5251f99331e37f4fac85654a6 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 30 Nov 2015 13:08:19 +0100 Subject: [PATCH] Gracefully handle empty CopyArea operations --- unix/xserver/hw/vnc/vncHooks.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/unix/xserver/hw/vnc/vncHooks.c b/unix/xserver/hw/vnc/vncHooks.c index eee26820..886c6466 100644 --- a/unix/xserver/hw/vnc/vncHooks.c +++ b/unix/xserver/hw/vnc/vncHooks.c @@ -1111,19 +1111,26 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int w, int h, int dstx, int dsty) { - BoxRec box; RegionRec dst, src, changed; RegionPtr ret; GC_OP_PROLOGUE(pGC, CopyArea); - box.x1 = dstx + pDst->x; - box.y1 = dsty + pDst->y; - box.x2 = box.x1 + w; - box.y2 = box.y1 + h; + // Apparently this happens now and then... + if ((w == 0) || (h == 0)) + REGION_NULL(pGC->pScreen, &dst); + else { + BoxRec box; + + box.x1 = dstx + pDst->x; + box.y1 = dsty + pDst->y; + box.x2 = box.x1 + w; + box.y2 = box.y1 + h; + + REGION_INIT(pGC->pScreen, &dst, &box, 0); + } - REGION_INIT(pGC->pScreen, &dst, &box, 0); REGION_INTERSECT(pGC->pScreen, &dst, &dst, pGC->pCompositeClip); // The source of the data has to be something that's on screen. @@ -1131,6 +1138,8 @@ static RegionPtr vncHooksCopyArea(DrawablePtr pSrc, DrawablePtr pDst, if ((pSrc->pScreen == pGC->pScreen) && ((pSrc->type == DRAWABLE_WINDOW) || (pSrc == &pGC->pScreen->GetScreenPixmap(pGC->pScreen)->drawable))) { + BoxRec box; + box.x1 = srcx + pSrc->x; box.y1 = srcy + pSrc->y; box.x2 = box.x1 + w; -- 2.39.5