image/jpeg: when following component selectors, only consider valid

components.

This fixes decoding JPEG images where the component selector is 0. Such
images are rare, but not impossible.

Change-Id: I6d221bce01cce8cc0440e117543233371782ca22
Reviewed-on: https://go-review.googlesource.com/6421
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Nigel Tao 2015-03-02 14:53:07 +11:00
parent 40ff393e4c
commit 0fe6b1293a

View file

@ -66,7 +66,7 @@ func (d *decoder) processSOS(n int) error {
for i := 0; i < nComp; i++ {
cs := d.tmp[1+2*i] // Component selector.
compIndex := -1
for j, comp := range d.comp {
for j, comp := range d.comp[:d.nComp] {
if cs == comp.c {
compIndex = j
}