Sometimes we get copy requests that are partially or fully outside the
framebuffer. Not sure if this is a bug or not, but for now add some handling
to deal with these gracefully.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4230 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/xserver/hw/vnc/vncHooks.cc b/unix/xserver/hw/vnc/vncHooks.cc
index 52ef42a..1bf61a3 100644
--- a/unix/xserver/hw/vnc/vncHooks.cc
+++ b/unix/xserver/hw/vnc/vncHooks.cc
@@ -400,12 +400,19 @@
int dx, dy;
RegionHelper copied(pScreen, pOldRegion);
+ BoxRec screen_box = {0, 0, pScreen->width, pScreen->height};
+ RegionHelper screen_rgn(pScreen, &screen_box, 1);
+
dx = pWin->drawable.x - ptOldOrg.x;
dy = pWin->drawable.y - ptOldOrg.y;
// RFB tracks copies in terms of destination rectangle, not source.
// We also need to copy with changes to the Window's clipping region.
+ // Finally, make sure we don't get copies to or from regions outside
+ // the framebuffer.
+ REGION_INTERSECT(pScreen, copied.reg, copied.reg, screen_rgn.reg);
REGION_TRANSLATE(pScreen, copied.reg, dx, dy);
+ REGION_INTERSECT(pScreen, copied.reg, copied.reg, screen_rgn.reg);
REGION_INTERSECT(pScreen, copied.reg, copied.reg, &pWin->borderClip);
(*pScreen->CopyWindow) (pWin, ptOldOrg, pOldRegion);