From 5cdb7b7beab06c8f7ca38b9143cfe25fc3b5f02e Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 25 Oct 2019 12:57:32 +0200 Subject: [PATCH] Fix gdi coordinate clamping. --- libfreerdp/gdi/gfx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index 4a393c3..09bba3f 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -133,12 +133,12 @@ static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface) { const UINT32 nXSrc = rects[i].left; const UINT32 nYSrc = rects[i].top; - const UINT32 nXDst = (UINT32)(surfaceX + nXSrc * sx); - const UINT32 nYDst = (UINT32)(surfaceY + nYSrc * sy); + const UINT32 nXDst = (UINT32)MIN(surfaceX + nXSrc * sx, gdi->width - 1); + const UINT32 nYDst = (UINT32)MIN(surfaceY + nYSrc * sy, gdi->height - 1); const UINT32 swidth = rects[i].right - rects[i].left; const UINT32 sheight = rects[i].bottom - rects[i].top; - const UINT32 dwidth = (UINT32)(swidth * sx); - const UINT32 dheight = (UINT32)(sheight * sy); + const UINT32 dwidth = MIN((UINT32)(swidth * sx), (UINT32)gdi->width - nXDst); + const UINT32 dheight = MIN((UINT32)(sheight * sy), (UINT32)gdi->height - nYDst); if (!freerdp_image_scale(gdi->primary_buffer, gdi->dstFormat, gdi->stride, nXDst, nYDst, dwidth, dheight, -- 2.7.4