Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image/jpeg: invalid memory address or nil pointer dereference #10389

Closed
dvyukov opened this issue Apr 8, 2015 · 0 comments
Closed

image/jpeg: invalid memory address or nil pointer dereference #10389

dvyukov opened this issue Apr 8, 2015 · 0 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Apr 8, 2015

Run the following program on the following input:

package main

import (
    "bytes"
    "image/jpeg"
    "io/ioutil"
    "os"
)

func main() {
    data, _ := ioutil.ReadFile(os.Args[1])
    img, err := jpeg.Decode(bytes.NewReader(data))
    if err != nil {
        return
    }
    var w bytes.Buffer
    err = jpeg.Encode(&w, img, nil)
    if err != nil {
        panic(err)
    }
}

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

It crashes with:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x18 pc=0x4566cc]

goroutine 1 [running]:
runtime.gopanic(0x4b2ac0, 0xc20800e260)
    src/runtime/panic.go:477 +0x3fe fp=0xc208041a70 sp=0xc2080419f0
runtime.panicmem()
    src/runtime/panic.go:42 +0x52 fp=0xc208041a98 sp=0xc208041a70
runtime.sigpanic()
    src/runtime/sigpanic_unix.go:24 +0x2bf fp=0xc208041ae8 sp=0xc208041a98
image/jpeg.(*decoder).processSOS(0xc208076000, 0x6, 0x0, 0x0)
    src/image/jpeg/scan.go:308 +0x11cc fp=0xc208041de8 sp=0xc208041ae8
image/jpeg.(*decoder).decode(0xc208076000, 0x7fd68274a1c0, 0xc208014450, 0x574300, 0x0, 0x0, 0x0, 0x0)
    src/image/jpeg/reader.go:619 +0xa4e fp=0xc208041e88 sp=0xc208041de8
image/jpeg.Decode(0x7fd68274a1c0, 0xc208014450, 0x0, 0x0, 0x0, 0x0)
    src/image/jpeg/reader.go:762 +0x69 fp=0xc208041ed0 sp=0xc208041e88
main.main()
    jpeg.go:12 +0x132 fp=0xc208041f90 sp=0xc208041ed0

My repository is on commit 8ac129e.

@dvyukov dvyukov added this to the Go1.5 milestone Apr 8, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants