mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
png: Update for Go 1.15
This commit is contained in:
parent
c43e8e24d5
commit
d48770cb1c
@ -165,8 +165,9 @@ func (d *decoder) parseIHDR(length uint32) error {
|
||||
if w <= 0 || h <= 0 {
|
||||
return FormatError("non-positive dimension")
|
||||
}
|
||||
nPixels := int64(w) * int64(h)
|
||||
if nPixels != int64(int(nPixels)) {
|
||||
nPixels64 := int64(w) * int64(h)
|
||||
nPixels := int(nPixels64)
|
||||
if nPixels64 != int64(nPixels) {
|
||||
return UnsupportedError("dimension overflow")
|
||||
}
|
||||
// There can be up to 8 bytes per pixel, for 16 bits per channel RGBA.
|
||||
@ -500,7 +501,10 @@ func (d *decoder) readImagePass(r io.Reader, pass int, allocateOnly bool) (image
|
||||
bytesPerPixel := (bitsPerPixel + 7) / 8
|
||||
|
||||
// The +1 is for the per-row filter type, which is at cr[0].
|
||||
rowSize := 1 + (bitsPerPixel*width+7)/8
|
||||
rowSize := 1 + (int64(bitsPerPixel)*int64(width)+7)/8
|
||||
if rowSize != int64(int(rowSize)) {
|
||||
return nil, UnsupportedError("dimension overflow")
|
||||
}
|
||||
// cr and pr are the bytes for the current and previous row.
|
||||
cr := make([]uint8, rowSize)
|
||||
pr := make([]uint8, rowSize)
|
||||
@ -860,8 +864,7 @@ func (d *decoder) parseIEND(length uint32) error {
|
||||
|
||||
func (d *decoder) parseChunk() error {
|
||||
// Read the length and chunk type.
|
||||
n, err := io.ReadFull(d.r, d.tmp[:8])
|
||||
if err != nil {
|
||||
if _, err := io.ReadFull(d.r, d.tmp[:8]); err != nil {
|
||||
return err
|
||||
}
|
||||
length := binary.BigEndian.Uint32(d.tmp[:4])
|
||||
@ -918,7 +921,7 @@ func (d *decoder) parseChunk() error {
|
||||
// Ignore this chunk (of a known length).
|
||||
var ignored [4096]byte
|
||||
for length > 0 {
|
||||
n, err = io.ReadFull(d.r, ignored[:min(len(ignored), int(length))])
|
||||
n, err := io.ReadFull(d.r, ignored[:min(len(ignored), int(length))])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user