]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix integer overflow in prove pass
authorJakub Ciolek <jakub@ciolek.dev>
Wed, 19 Nov 2025 10:17:47 +0000 (11:17 +0100)
committerKeith Randall <khr@golang.org>
Fri, 21 Nov 2025 18:34:21 +0000 (10:34 -0800)
commitf87aaec53d943eb2b5a6b9be9e4af284543c4004
treee09435d46390a6e3a6b5b67c9e2aebbb7cfd0723
parentdbd2ab999262e1c9304d0591d6883f83b09c8570
cmd/compile: fix integer overflow in prove pass

The detectSliceLenRelation function incorrectly deduced lower bounds
for "len(s) - i" without checking if the subtraction could overflow
(e.g. when i is negative). This led to incorrect elimination of
bounds checks.

Fixes: #76355
Change-Id: I30ada0e5f1425929ddd8ae1b66e55096ec209b5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/721920
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/ssa/prove.go
test/prove.go