Index: vnc.c =================================================================== --- vnc.c (revision 4615) +++ vnc.c (working copy) @@ -854,6 +854,11 @@ { int i; vs->need_update = 1; + + if (x_position + w > vs->ds->width) w = vs->ds->width - x_position; + if (y_position + h > vs->ds->height) h = vs->ds->height - y_position; + if (w <= 0 || h <= 0) return; + if (!incremental) { char *old_row = vs->old_data + y_position * vs->ds->linesize;