Skip to content

image/gif: Decode returns an image with empty palette #11150

Closed
@dvyukov

Description

The following program crashes with the panic:

package main

import (
    "bytes"
    "image/gif"
)

func main() {
    data := []byte("GIF89a000\x00000,00\x00\x00\x00\x000\x000\x02\b\r0000000\x00;")
    img, err := gif.Decode(bytes.NewReader(data))
    if err != nil {
        panic(err)
    }
    var w bytes.Buffer
    err = gif.Encode(&w, img, nil)
    if err != nil {
        panic(err)
    }
    _, err = gif.Decode(&w)
    if err != nil {
        panic(err)
    }
}
panic: gif: cannot encode image block with empty palette

goroutine 1 [running]:
main.main()
    gif.go:17 +0x219

Decode should not return an image with empty palette, it should return an error instead.

go version devel +b0532a9 Mon Jun 8 05:13:15 2015 +0000 linux/amd64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions