From 217efab71103443af6bfcc75020cb3f6f2de5d31 Mon Sep 17 00:00:00 2001 From: Jonah Uellenberg Date: Thu, 27 Nov 2025 20:39:37 -0800 Subject: [PATCH] runtime: add explicit lower bounds check to decoderune By doing a full bounds check here, we eliminate the auto generated one, which makes the codegen slightly better. Requires I39ba2a18cbabc0559924d4d226dcb99dbe9a06ed for BCE, although this can be merged before it. --- src/runtime/utf8.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/utf8.go b/src/runtime/utf8.go index 52b757662d0e7b..7a476a67b2a50f 100644 --- a/src/runtime/utf8.go +++ b/src/runtime/utf8.go @@ -60,7 +60,7 @@ func countrunes(s string) int { func decoderune(s string, k int) (r rune, pos int) { pos = k - if k >= len(s) { + if k < 0 || k >= len(s) { return runeError, k + 1 }