imaging icon indicating copy to clipboard operation
imaging copied to clipboard

Panic in the Rotate90 function.

Open hsnks100 opened this issue 1 year ago • 0 comments

The following code

package main

import (
	"image"

	"github.com/disintegration/imaging"
)

func Test() {
	yStride := 288
	cStride := 144
	width := 288
	height := 147

	im := &image.YCbCr{
		Y:              make([]uint8, yStride*height),
		Cb:             make([]uint8, (cStride*height)/2),
		Cr:             make([]uint8, (cStride*height)/2),
		YStride:        yStride,
		CStride:        yStride / 2,
		SubsampleRatio: image.YCbCrSubsampleRatio420,
		Rect: image.Rectangle{
			Min: image.Point{
				X: 0,
				Y: 0,
			},
			Max: image.Point{
				X: width,
				Y: height,
			},
		},
	}
	imaging.Rotate90(im)
}
func main() {
	Test()
}

result

go build && ./ip
panic: runtime error: index out of range [10654] with length 10584

goroutine 21 [running]:
github.com/disintegration/imaging.(*scanner).scan(0xc000116040, 0x11d, 0x0, 0x11e, 0x93, {0xc000180498, 0x0?, 0x290e8})
        /Users/diallo/go/pkg/mod/github.com/disintegration/[email protected]/scanner.go:202 +0x8f0
github.com/disintegration/imaging.Rotate90.func1(0x0?)
        /Users/diallo/go/pkg/mod/github.com/disintegration/[email protected]/transform.go:90 +0x6c
github.com/disintegration/imaging.parallel.func1()
        /Users/diallo/go/pkg/mod/github.com/disintegration/[email protected]/utils.go:33 +0x63
created by github.com/disintegration/imaging.parallel
        /Users/diallo/go/pkg/mod/github.com/disintegration/[email protected]/utils.go:31 +0xd6

There seems to be a problem when height is an odd number.

hsnks100 avatar Apr 11 '23 05:04 hsnks100