Skip to content

Commit

Permalink
gopls/internal/cache/parsego: fix OOB crash in fixInitStmt
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
adonovan authored and gopherbot committed Mar 3, 2025
1 parent 2b1f550 commit 455db21
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gopls/internal/cache/parsego/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,11 @@ func fixInitStmt(bad *ast.BadExpr, parent ast.Node, tok *token.File, src []byte)
}

// Try to extract a statement from the BadExpr.
start, end, err := safetoken.Offsets(tok, bad.Pos(), bad.End()-1)
start, end, err := safetoken.Offsets(tok, bad.Pos(), bad.End())
if err != nil {
return false
}
stmtBytes := src[start : end+1]
stmtBytes := src[start:end]
stmt, err := parseStmt(tok, bad.Pos(), stmtBytes)
if err != nil {
return false
Expand Down

0 comments on commit 455db21

Please sign in to comment.