Skip to content

Commit

Permalink
Merge pull request #29 from william8000/xvjpeg-bug-1sep24
Browse files Browse the repository at this point in the history
xvjpeg.c: Fix a bad memory access on jpegs with inverted data
  • Loading branch information
mdadams authored Sep 1, 2024
2 parents b5bd5c2 + f94cb44 commit 8cd5e98
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/xvjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,14 @@ int LoadJFIF(char *fname, PICINFO *pinfo, int quick)
if (cinfo.saw_Adobe_marker) { /* assume inverted data */
register byte *q = pic;

do {
while (q < pic_end) {
register int cmy, k = 255 - q[3];

if ((cmy = *q++ - k) < 0) { cmy = 0; } *p++ = cmy; /* R */
if ((cmy = *q++ - k) < 0) { cmy = 0; } *p++ = cmy; /* G */
if ((cmy = *q++ - k) < 0) { cmy = 0; } *p++ = cmy; /* B */
} while (++q <= pic_end);
q++;
}
}
else { /* assume normal data */
register byte *q = pic;
Expand Down

0 comments on commit 8cd5e98

Please sign in to comment.