lint/lintutil/format: avoid panic in Stylish if first Position to report is empty
Pointer tw was not initialised before use, if the first call to Format
was with an empty Position, leading to panic. This change forces the
Filename to be something ("-"), to avoid that.
Closes: [via git-merge-pr]
@@ -102,6 +102,10 @@ type Stylish struct {
}
func (o *Stylish) Format(p lint.Problem) {
+ if p.Position.Filename == "" {
+ p.Position.Filename = "-"
+ }
+
if p.Position.Filename != o.prevFile {
if o.prevFile != "" {
o.tw.Flush()
