Skip to content

Commit

Permalink
Fix missing bounds check in errorf verb matching (fixes #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfloyd committed Sep 29, 2022
1 parent 2a7b31d commit 28e7f6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions errorlint/printf.go
Expand Up @@ -14,6 +14,9 @@ func verbOrder(verbs []verb, numArgs int) [][]verb {
if v.index != -1 {
i = v.index - 1
}
if i >= len(orderedVerbs) {
continue
}
orderedVerbs[i] = append(orderedVerbs[i], v)
verbs = verbs[1:]
i++
Expand Down
8 changes: 8 additions & 0 deletions errorlint/testdata/src/issues/github-29.go
@@ -0,0 +1,8 @@
package issues

import "fmt"

func Issue29() {
err := fmt.Errorf("%v %#[2]v", struct{ string }{})
fmt.Println(err)
}

0 comments on commit 28e7f6b

Please sign in to comment.