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: index out of range #10388

Closed
dvyukov opened this issue Apr 8, 2015 · 1 comment
Closed

image/jpeg: index out of range #10388

dvyukov opened this issue Apr 8, 2015 · 1 comment
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/0B20Uwp8Hs1oCSnFPQTIxU0FyR1E/view?usp=sharing

It crashes with:

panic: runtime error: index out of range

goroutine 1 [running]:
runtime.gopanic(0x4b2ac0, 0xc20800e210)
    src/runtime/panic.go:477 +0x3fe fp=0xc208041ac0 sp=0xc208041a40
runtime.panicindex()
    src/runtime/panic.go:12 +0x52 fp=0xc208041ae8 sp=0xc208041ac0
image/jpeg.(*decoder).processSOS(0xc208070000, 0xa, 0x0, 0x0)
    src/image/jpeg/scan.go:218 +0x1ca3 fp=0xc208041de8 sp=0xc208041ae8
image/jpeg.(*decoder).decode(0xc208070000, 0x7f7d0183b1c0, 0xc208014450, 0x574300, 0x0, 0x0, 0x0, 0x0)
    src/image/jpeg/reader.go:619 +0xa4e fp=0xc208041e88 sp=0xc208041de8
image/jpeg.Decode(0x7f7d0183b1c0, 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
@nigeltao
Copy link
Contributor

This is the same problem (multiple SOF markers) as issue #10389, and was fixed by eb44082.

@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