From 4a5ec4f03cf1061658648af5e3bfbe50c14f693b Mon Sep 17 00:00:00 2001 From: Nick White Date: Thu, 17 Nov 2022 12:58:24 +0000 Subject: More bounds checking with bottomRight to prevent possible panic in zero size images --- integral.go | 3 +++ 1 file changed, 3 insertions(+) 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] } -- cgit v1.2.1-24-ge1ad