Skip to content

Commit 28e7f6b

Browse files
committed
Fix missing bounds check in errorf verb matching (fixes #29)
1 parent 2a7b31d commit 28e7f6b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

errorlint/printf.go

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ func verbOrder(verbs []verb, numArgs int) [][]verb {
1414
if v.index != -1 {
1515
i = v.index - 1
1616
}
17+
if i >= len(orderedVerbs) {
18+
continue
19+
}
1720
orderedVerbs[i] = append(orderedVerbs[i], v)
1821
verbs = verbs[1:]
1922
i++
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package issues
2+
3+
import "fmt"
4+
5+
func Issue29() {
6+
err := fmt.Errorf("%v %#[2]v", struct{ string }{})
7+
fmt.Println(err)
8+
}

0 commit comments

Comments
 (0)