Skip to content

Commit 217efab

Browse files
committed
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.
1 parent cead111 commit 217efab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/runtime/utf8.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func countrunes(s string) int {
6060
func decoderune(s string, k int) (r rune, pos int) {
6161
pos = k
6262

63-
if k >= len(s) {
63+
if k < 0 || k >= len(s) {
6464
return runeError, k + 1
6565
}
6666

0 commit comments

Comments
 (0)