http://www.w3.org/TR/PNG/#11IHDR says that "Zero is an invalid value".
This change only affects the decoder. The encoder already checks
non-positive instead of negative.
Fixes #12545.
Change-Id: Iba40e1a2f4e0eec8b2fbcd3bbdae886311434da7
Reviewed-on: https://go-review.googlesource.com/14411
Reviewed-by: Rob Pike <r@golang.org>
d.interlace = int(d.tmp[12])
w := int32(binary.BigEndian.Uint32(d.tmp[0:4]))
h := int32(binary.BigEndian.Uint32(d.tmp[4:8]))
- if w < 0 || h < 0 {
- return FormatError("negative dimension")
+ if w <= 0 || h <= 0 {
+ return FormatError("non-positive dimension")
}
nPixels := int64(w) * int64(h)
if nPixels != int64(int(nPixels)) {