mirror of
https://github.com/golang/go
synced 2024-11-24 21:00:09 -07:00
image/gif: avoid decoding past the first frame in decode()
The existing decode() method offers the ability to keep just one frame of the GIF image, however it will read and decompress all subsequent frames regardless. Fixes #41142
This commit is contained in:
parent
45f251ad6c
commit
03ebc8ee7b
@ -250,6 +250,10 @@ func (d *decoder) decode(r io.Reader, configOnly, keepAllFrames bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if !keepAllFrames && len(d.image) == 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
case sTrailer:
|
||||
if len(d.image) == 0 {
|
||||
return fmt.Errorf("gif: missing image data")
|
||||
|
@ -379,7 +379,7 @@ func TestLoopCount(t *testing.T) {
|
||||
|
||||
func TestUnexpectedEOF(t *testing.T) {
|
||||
for i := len(testGIF) - 1; i >= 0; i-- {
|
||||
_, err := Decode(bytes.NewReader(testGIF[:i]))
|
||||
_, err := DecodeAll(bytes.NewReader(testGIF[:i]))
|
||||
if err == errNotEnough {
|
||||
continue
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user