Fix potential panic in NewStreamTokenFromString caused by off-by-one error (#2196)

Line 291 could panic when trying to set `positions[i]` if `i == len(positions)`.
This commit is contained in:
Neil Alexander 2022-02-17 13:25:41 +00:00 committed by GitHub
parent 89b7519089
commit 353168a9e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -279,7 +279,7 @@ func NewStreamTokenFromString(tok string) (token StreamingToken, err error) {
parts := strings.Split(tok[1:], "_") parts := strings.Split(tok[1:], "_")
var positions [7]StreamPosition var positions [7]StreamPosition
for i, p := range parts { for i, p := range parts {
if i > len(positions) { if i >= len(positions) {
break break
} }
var pos int var pos int