mirror of
https://github.com/golang/go
synced 2024-11-24 06:40:17 -07:00
go/doc: fix incorrect indentifier decoding in comments
This code was trying to decode each codepoint one by one, but didn't resliced the string, so it was instead reading the first codepoint over and over, if the string length was not a multiple of the codepoint length, this would cause us to walk past the end of the string. This was a latent bug introduced in CL 397277 but was revealed to OSS-Fuzz in CL 384265. Fixes #52353
This commit is contained in:
parent
0c6d8bb109
commit
424f6cfad1
@ -1063,7 +1063,7 @@ func ident(s string) (id string, ok bool) {
|
||||
}
|
||||
break
|
||||
}
|
||||
r, nr := utf8.DecodeRuneInString(s)
|
||||
r, nr := utf8.DecodeRuneInString(s[n:])
|
||||
if unicode.IsLetter(r) {
|
||||
n += nr
|
||||
continue
|
||||
|
12
src/go/doc/comment/parse_test.go
Normal file
12
src/go/doc/comment/parse_test.go
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2022 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package comment
|
||||
|
||||
import "testing"
|
||||
|
||||
// See https://golang.org/issue/52353
|
||||
func Test52353(t *testing.T) {
|
||||
ident("𫕐ﯯ")
|
||||
}
|
Loading…
Reference in New Issue
Block a user