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 }