summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-12-14 11:11:27 +0000
committerNick White <git@njw.name>2020-12-14 11:11:27 +0000
commitb992e8482c6302af8e804c1b065ba8b8016561bb (patch)
treed3dd192a18d8928957337cf6deb241d078f3977c
parent72828cfade32177c22f1d6e343ba42e0438b7fd8 (diff)
Fix panic if no good edge is found in wiperv0.4.1
If findbestedge() found no good edges at all (which is rare but can happen), then it would panic.
-rw-r--r--wipesides.go3
1 files changed, 3 insertions, 0 deletions
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