summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2022-11-17 12:58:24 +0000
committerNick White <git@njw.name>2022-11-17 12:58:24 +0000
commit4a5ec4f03cf1061658648af5e3bfbe50c14f693b (patch)
tree20102ca5bee5d5045c030e393a48f10b4d7ec3cf
parent2e923f2991d4070d86bd5d63a5434f30ce570fd3 (diff)
More bounds checking with bottomRight to prevent possible panic in zero size imagesHEADv0.6.1master
-rw-r--r--integral.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/integral.go b/integral.go
index e3d09bb..99a4da7 100644
--- a/integral.go
+++ b/integral.go
@@ -176,6 +176,9 @@ func (i Image) bottomRight(r image.Rectangle) uint64 {
b := i.Bounds()
x := lowest(r.Max.X-1, b.Max.X-1)
y := lowest(r.Max.Y-1, b.Max.Y-1)
+ if x < 0 || y < 0 {
+ return 0
+ }
return i[y][x]
}