Skip to content

Commit

Permalink
Merge pull request #69 from nopdotcom/master
Browse files Browse the repository at this point in the history
Avoid divide-by-zero in raw encoding (OSX RealVNC)
  • Loading branch information
bk138 committed Apr 17, 2015
2 parents b7946a6 + 79d938c commit f5abd4a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libvncclient/rfbproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,10 @@ HandleRFBServerMessage(rfbClient* client)
int y=rect.r.y, h=rect.r.h;

bytesPerLine = rect.r.w * client->format.bitsPerPixel / 8;
linesToRead = RFB_BUFFER_SIZE / bytesPerLine;
/* RealVNC 4.x-5.x on OSX can induce bytesPerLine==0,
usually during GPU accel. */
/* Regardless of cause, do not divide by zero. */
linesToRead = bytesPerLine ? (RFB_BUFFER_SIZE / bytesPerLine) : 0;

while (h > 0) {
if (linesToRead > h)
Expand Down

0 comments on commit f5abd4a

Please sign in to comment.