golang/go

x/image/webp: invalid memory address or nil pointer dereference

dvyukov opened this issue · 1 comments

Run the following program on the following file:

package main

import (
    "bytes"
    "golang.org/x/image/webp"
    "io/ioutil"
    "os"
)

func main() {
    data, _ := ioutil.ReadFile(os.Args[1])
    webp.Decode(bytes.NewReader(data))
}

https://drive.google.com/file/d/0B20Uwp8Hs1oCdDNyc2x5eWtvVUU/view?usp=sharing

Crashes with:

runtime.sigpanic()
    src/runtime/sigpanic_unix.go:24 +0x2bf fp=0xc208041a10 sp=0xc2080419c0
golang.org/x/image/riff.(*chunkReader).Read(0x0, 0xc208076000, 0x2000, 0x2000, 0x1, 0x0, 0x0)
    golang.org/x/image/riff/riff.go:151 +0x44 fp=0xc208041aa8 sp=0xc208041a10
io/ioutil.devNull.ReadFrom(0x0, 0x7f0b7195f1e8, 0x0, 0x0, 0x0, 0x0)
    src/io/ioutil/ioutil.go:151 +0xa1 fp=0xc208041b00 sp=0xc208041aa8
io/ioutil.(*devNull).ReadFrom(0xc20800e550, 0x7f0b7195f1e8, 0x0, 0xc208041bb8, 0x0, 0x0)
    <autogenerated>:9 +0xb4 fp=0xc208041b38 sp=0xc208041b00
io.Copy(0x7f0b7195f120, 0xc20800e550, 0x7f0b7195f1e8, 0x0, 0x0, 0x0, 0x0)
    src/io/io.go:358 +0x183 fp=0xc208041c10 sp=0xc208041b38
golang.org/x/image/riff.(*Reader).Next(0xc2080104c0, 0x0, 0x0, 0x0, 0x0, 0x0)
    golang.org/x/image/riff/riff.go:103 +0x123 fp=0xc208041cb8 sp=0xc208041c10
golang.org/x/image/webp.decode(0x7f0b7195f1c0, 0xc2080143f0, 0x401e00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    golang.org/x/image/webp/decode.go:52 +0x1c7 fp=0xc208041ea8 sp=0xc208041cb8
golang.org/x/image/webp.Decode(0x7f0b7195f1c0, 0xc2080143f0, 0x0, 0x0, 0x0, 0x0)
    golang.org/x/image/webp/decode.go:256 +0x55 fp=0xc208041f08 sp=0xc208041ea8
main.main()
    webp.go:12 +0x10b fp=0xc208041f90 sp=0xc208041f08

My repository is on commit 65a798f031fd31a65574938bed2ec44c2bcba496.

CL https://golang.org/cl/9839 mentions this issue.