Skip to content

Commit

Permalink
tiff/lzw: don't follow code == hi if last is invalid
Browse files Browse the repository at this point in the history
This does for x/image what
https://go-review.googlesource.com/c/go/+/45111/ did for the standard
library's compress/lzw.

The x variant is a fork of the stdlib, with an extra, explicit tweak
because the TIFF format is "off by one" - a mistake (not Go specific)
somebody introduced decades ago and that we can never fix, given all the
existing TIFF files out there in the wild.

When previously patching the stdlib variant, I was supposed to also
patch the x variant, but forgot.

Updates golang/go#11386

Change-Id: Ic74f9014d2d048ee12cdd151332db62b76f1cde2
Reviewed-on: https://go-review.googlesource.com/c/image/+/191221
Reviewed-by: Bryan C. Mills <bcmills@google.com>
  • Loading branch information
yi-ge3 committed Feb 26, 2023
1 parent 07cd84a commit f02f168
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tiff/lzw/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ loop:
break loop
case code <= d.hi:
c, i := code, len(d.output)-1
if code == d.hi {
if code == d.hi && d.last != decoderInvalidCode {
// code == hi is a special case which expands to the last expansion
// followed by the head of the last expansion. To find the head, we walk
// the prefix chain until we find a literal code.
Expand Down

0 comments on commit f02f168

Please sign in to comment.