diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c index 3a29e53..b7d6a75 100644 --- a/libvncclient/rfbproto.c +++ b/libvncclient/rfbproto.c @@ -143,7 +143,7 @@ static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int #define COPY_RECT(BPP) \ { \ int rs = w * BPP / 8, rs2 = client->width * BPP / 8; \ - for (j = x + y * rs2; j < (y + h) * rs2; j += rs2) { \ + for (j = ((x * (BPP / 8)) + (y * rs2)); j < (y + h) * rs2; j += rs2) { \ memcpy(client->frameBuffer + j, buffer, rs); \ buffer += rs; \ } \