]> Cypherpunks repositories - gostls13.git/commitdiff
image/png: update palette out-of-bounds comment.
authorNigel Tao <nigeltao@golang.org>
Fri, 2 Nov 2012 06:20:19 +0000 (17:20 +1100)
committerNigel Tao <nigeltao@golang.org>
Fri, 2 Nov 2012 06:20:19 +0000 (17:20 +1100)
R=r
CC=golang-dev
https://golang.org/cl/6817070

src/pkg/image/png/reader.go

index 5674f18398b42a806721a57b96afe3ddbf9634e2..ff837331f81b991ee0768bc62849c2b5c9a7a03c 100644 (file)
@@ -198,10 +198,11 @@ func (d *decoder) parsePLTE(length uint32) error {
                        d.palette[i] = color.RGBA{d.tmp[3*i+0], d.tmp[3*i+1], d.tmp[3*i+2], 0xff}
                }
                for i := np; i < 256; i++ {
-                       // Initialize the rest of the palette to opaque black. The spec isn't
-                       // clear whether palette index values outside of those defined by the PLTE
-                       // chunk is an error: libpng 1.5.13 falls back to opaque black, the
-                       // same as we do here, ImageMagick 6.5.7 returns an error.
+                       // Initialize the rest of the palette to opaque black. The spec (section
+                       // 11.2.3) says that "any out-of-range pixel value found in the image data
+                       // is an error", but some real-world PNG files have out-of-range pixel
+                       // values. We fall back to opaque black, the same as libpng 1.5.13;
+                       // ImageMagick 6.5.7 returns an error.
                        d.palette[i] = color.RGBA{0x00, 0x00, 0x00, 0xff}
                }
                d.palette = d.palette[:np]