Skip to content

Commit 8aa94a3

Browse files
committed
Fix bug that crash with negative width/height
1 parent a8fac8f commit 8aa94a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sixel.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ const (
3737
func (e *Encoder) Encode(img image.Image) error {
3838
nc := 255 // (>= 2, 8bit, index 0 is reserved for transparent key color)
3939
width, height := img.Bounds().Dx(), img.Bounds().Dy()
40-
if e.Width != 0 {
40+
if width == 0 || height == 0 {
41+
return nil
42+
}
43+
if e.Width > 0 {
4144
width = e.Width
4245
}
43-
if e.Height != 0 {
46+
if e.Height > 0 {
4447
height = e.Height
4548
}
4649

0 commit comments

Comments
 (0)