mirror of
https://github.com/golang/go
synced 2024-11-19 15:44: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 {
|
if _, err := w.Write(buf[i:]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Save what the hi code expands to.
|
if last != invalidCode {
|
||||||
suffix[hi] = uint8(c)
|
// Save what the hi code expands to.
|
||||||
prefix[hi] = last
|
suffix[hi] = uint8(c)
|
||||||
|
prefix[hi] = last
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return os.NewError("lzw: invalid code")
|
return os.NewError("lzw: invalid code")
|
||||||
}
|
}
|
||||||
last, hi = code, hi+1
|
last, hi = code, hi+1
|
||||||
if hi == overflow {
|
if hi >= overflow {
|
||||||
if d.width == maxWidth {
|
if d.width == maxWidth {
|
||||||
return os.NewError("lzw: missing clear code")
|
last = invalidCode
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
d.width++
|
d.width++
|
||||||
overflow <<= 1
|
overflow <<= 1
|
||||||
|
Loading…
Reference in New Issue
Block a user