Limit RFX update region to screen.
authorArmin Novak <armin.novak@gmail.com>
Sat, 11 Feb 2017 10:13:14 +0000 (11:13 +0100)
committerArmin Novak <armin.novak@thincast.com>
Mon, 13 Feb 2017 14:26:21 +0000 (15:26 +0100)
libfreerdp/codec/rfx.c

index 16daad0..c887846 100644 (file)
@@ -1157,10 +1157,10 @@ BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length,
                {
                        RECTANGLE_16 clippingRect;
                        const RFX_RECT* rect = &(message->rects[i]);
-                       clippingRect.left = left + rect->x;
-                       clippingRect.top = top + rect->y;
-                       clippingRect.right = clippingRect.left + rect->width;
-                       clippingRect.bottom = clippingRect.top + rect->height;
+                       clippingRect.left = MIN(left + rect->x, dstWidth);
+                       clippingRect.top = MIN(top + rect->y, dstHeight);
+                       clippingRect.right = MIN(clippingRect.left + rect->width, dstWidth);
+                       clippingRect.bottom = MIN(clippingRect.top + rect->height, dstHeight);
                        region16_union_rect(&clippingRects, &clippingRects, &clippingRect);
                }
 
@@ -1178,19 +1178,13 @@ BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data, UINT32 length,
 
                        for (j = 0; j < nbUpdateRects; j++)
                        {
-                               UINT32 stride = 64 * formatSize;
-                               UINT32 nXDst = updateRects[j].left;
-                               UINT32 nYDst = updateRects[j].top;
-                               UINT32 nXSrc = nXDst - updateRect.left;
-                               UINT32 nYSrc = nYDst - updateRect.top;
-                               UINT32 nWidth = MIN(64, updateRects[j].right - updateRects[j].left);
-                               UINT32 nHeight = MIN(64, updateRects[j].bottom - updateRects[j].top);
-
-                               if (nXDst + nWidth > dstWidth)
-                                       nWidth = MAX(0, dstWidth - nXDst);
-
-                               if (nYDst + nHeight > dstHeight)
-                                       nHeight = MAX(0, dstHeight - nYDst);
+                               const UINT32 stride = 64 * formatSize;
+                               const UINT32 nXDst = updateRects[j].left;
+                               const UINT32 nYDst = updateRects[j].top;
+                               const UINT32 nXSrc = nXDst - updateRect.left;
+                               const UINT32 nYSrc = nYDst - updateRect.top;
+                               const UINT32 nWidth = updateRects[j].right - updateRects[j].left;
+                               const UINT32 nHeight = updateRects[j].bottom - updateRects[j].top;
 
                                if (!freerdp_image_copy(dst, dstFormat, dstStride,
                                                        nXDst, nYDst, nWidth, nHeight,