Skip to content

Commit

Permalink
internal/analysisinternal: prevent fillstruct panic on nil package
Browse files Browse the repository at this point in the history
The previous implementation missed a nil check which caused a panic
when the package of a type was nil.

Fixes: golang/go#39899
Change-Id: I2dfb50d6b79f52df367e093e5d857cd70b7cef27
Reviewed-on: https://go-review.googlesource.com/c/tools/+/240537
Run-TryBot: Josh Baum <joshbaum@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
(cherry picked from commit aa3d501)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/240538
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Josh Baum <joshbaum@google.com>
  • Loading branch information
joshbaum authored and stamblerre committed Jun 30, 2020
1 parent e1c39cc commit cbc3639
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/analysisinternal/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func TypeExpr(fset *token.FileSet, f *ast.File, pkg *types.Package, typ types.Ty
return ast.NewIdent(t.Name())
}
case *types.Named:
if t.Obj().Pkg() == nil {
return nil
}
if t.Obj().Pkg() == pkg {
return ast.NewIdent(t.Obj().Name())
}
Expand Down

0 comments on commit cbc3639

Please sign in to comment.