mirror of
https://github.com/golang/go
synced 2024-11-21 19:14:44 -07:00
compress/lzw: silently drop implied codes that are too large,
instead of returning an error. For example, http://www.w3.org/Graphics/GIF/spec-gif89a.txt explicitly says that GIF encoders can use a full table as is, without needing to send a clear code. R=r, dsymonds, nigeltao_gnome, r2 CC=golang-dev https://golang.org/cl/4518041
This commit is contained in:
parent
a4dee3a746
commit
f467803dcd
@ -165,16 +165,19 @@ func decode1(pw *io.PipeWriter, r io.ByteReader, read func(*decoder) (uint16, os
|
||||
if _, err := w.Write(buf[i:]); err != nil {
|
||||
return err
|
||||
}
|
||||
if last != invalidCode {
|
||||
// Save what the hi code expands to.
|
||||
suffix[hi] = uint8(c)
|
||||
prefix[hi] = last
|
||||
}
|
||||
default:
|
||||
return os.NewError("lzw: invalid code")
|
||||
}
|
||||
last, hi = code, hi+1
|
||||
if hi == overflow {
|
||||
if hi >= overflow {
|
||||
if d.width == maxWidth {
|
||||
return os.NewError("lzw: missing clear code")
|
||||
last = invalidCode
|
||||
continue
|
||||
}
|
||||
d.width++
|
||||
overflow <<= 1
|
||||
|
Loading…
Reference in New Issue
Block a user