Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in the Rotate90 function. #159

Open
hsnks100 opened this issue Apr 11, 2023 · 0 comments
Open

Panic in the Rotate90 function. #159

hsnks100 opened this issue Apr 11, 2023 · 0 comments

Comments

@hsnks100
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant