Skip to content

Commit

Permalink
image/jpeg: when following component selectors, only consider valid
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nigeltao committed Mar 3, 2015
1 parent 40ff393 commit 0fe6b12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/image/jpeg/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 0fe6b12

Please sign in to comment.