Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
Fix off-by-one problem causing copy-and-paste corruption when in 24-b…
Browse files Browse the repository at this point in the history
…it mode.

This is from xv-20100523-ville-saari-clipboard-colormap-fix.dif

The report states that it happens when the selected area has 256
distinct colors or fewer.

Here's how to trigger the bug:  To make it easy, I picked a .gif with
just three colors: blue (000084), red (ff0000), and white (ffffff).
Well...  Three colors plus the other ones in between to do
anti-aliasing.  Anyhow...

Press Meta-8 (Alt-8) to go into 24-bit mode. Select a small area, maybe
60 pixels wide.  Crop it (press 'c'), then stretch out the image window
so the individual pixels are around 5mm on your monitor.  Select a piece
of image.  Right-click on the image to get the controls window.  Press
the "copy" button.  Click the image outside the selection box to get rid
of the box.  Press the "paste" button.  This will bring up a new
selection box which indicates where the contents of the clipboard will
be pasted.  Move that box somewhere else.  Press the "paste" button
again.  What you paste will be sprinkled with what looks like confetti.
  • Loading branch information
DavidGriffith committed Apr 29, 2017
1 parent 13d2926 commit d43d02e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion xv.h
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@

#define STDINSTR "<stdin>"


#ifndef MAIN
#define WHERE extern
#else
Expand Down
2 changes: 1 addition & 1 deletion xvcut.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,10 @@ static byte *getSelection()
if (pr==cm[0] && pg==cm[1] && pb==cm[2]) break;
}
if (k==nc) {
nc++;
cimg[CIMG_CMAP + nc*3 ] = pr;
cimg[CIMG_CMAP + nc*3 + 1] = pg;
cimg[CIMG_CMAP + nc*3 + 2] = pb;
nc++;
}

*dp++ = (byte) k;
Expand Down

0 comments on commit d43d02e

Please sign in to comment.