From b992e8482c6302af8e804c1b065ba8b8016561bb Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 14 Dec 2020 11:11:27 +0000 Subject: Fix panic if no good edge is found in wiper If findbestedge() found no good edges at all (which is rare but can happen), then it would panic. --- wipesides.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wipesides.go b/wipesides.go index 9183479..b9f5e5c 100644 --- a/wipesides.go +++ b/wipesides.go @@ -55,6 +55,9 @@ func findbestedge(img SummableImage, x int, w int) int { bestxs = append(bestxs, x) } } + if len(bestxs) == 0 { + return 0 + } middlex := bestxs[len(bestxs)/2] return middlex -- cgit v1.2.1-24-ge1ad