diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c index 132b338e..38644ae1 100644 --- a/xrdp/xrdp_painter.c +++ b/xrdp/xrdp_painter.c @@ -610,13 +610,13 @@ xrdp_painter_copy(struct xrdp_painter* self, y += dy; palette_id = 0; j = srcy; - while (j < src->height) + while (j < (srcy + cy)) { i = srcx; - while (i < src->width) + while (i < (srcx + cx)) { - w = MIN(64, src->width - i); - h = MIN(64, src->height - j); + w = MIN(64, (srcx + cx) - i); + h = MIN(64, (srcy + cy) - j); b = xrdp_bitmap_create(w, h, self->wm->screen->bpp, 0, self->wm); xrdp_bitmap_copy_box_with_crc(src, b, i, j, w, h); bitmap_id = xrdp_cache_add_bitmap(self->wm->cache, b);