Skip to content

Commit 455db21

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/cache/parsego: fix OOB crash in fixInitStmt
This is a priori not how to use safetoken. I haven't attempted to reproduce the crash. Fixes golang/go#72026 Change-Id: I7a95383032f9a882c8b667203bbe0cf06f85a987 Reviewed-on: https://go-review.googlesource.com/c/tools/+/653596 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 2b1f550 commit 455db21

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gopls/internal/cache/parsego/parse.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,11 @@ func fixInitStmt(bad *ast.BadExpr, parent ast.Node, tok *token.File, src []byte)
528528
}
529529

530530
// Try to extract a statement from the BadExpr.
531-
start, end, err := safetoken.Offsets(tok, bad.Pos(), bad.End()-1)
531+
start, end, err := safetoken.Offsets(tok, bad.Pos(), bad.End())
532532
if err != nil {
533533
return false
534534
}
535-
stmtBytes := src[start : end+1]
535+
stmtBytes := src[start:end]
536536
stmt, err := parseStmt(tok, bad.Pos(), stmtBytes)
537537
if err != nil {
538538
return false

0 commit comments

Comments
 (0)