From 4d609f6fa1aa95591ef4ed502b41c33a62d71cb6 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 14 Jan 2023 14:05:27 -0500 Subject: [PATCH] Line no longer segfaults --- artist/line.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/artist/line.go b/artist/line.go index 03ee97f..698dfe8 100644 --- a/artist/line.go +++ b/artist/line.go @@ -52,6 +52,7 @@ func lineLow ( width, height int, ) { data, stride := destination.Buffer() + bounds := destination.Bounds() deltaX := max.X - min.X deltaY := max.Y - min.Y @@ -66,6 +67,7 @@ func lineLow ( y := min.Y for x := min.X; x < max.X; x ++ { + if !(image.Point { x, y }).In(bounds) { break } data[x + y * stride] = source.AtWhen(x, y, width, height) if D > 0 { y += yi @@ -85,6 +87,7 @@ func lineHigh ( width, height int, ) { data, stride := destination.Buffer() + bounds := destination.Bounds() deltaX := max.X - min.X deltaY := max.Y - min.Y @@ -99,6 +102,7 @@ func lineHigh ( x := min.X for y := min.Y; y < max.Y; y ++ { + if !(image.Point { x, y }).In(bounds) { break } data[x + y * stride] = source.AtWhen(x, y, width, height) if D > 0 { x += xi