From 4cea89713c0fb3f5ff8ac1244cecd795509986c5 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Wed, 15 Jul 2020 13:13:59 -0400 Subject: [PATCH] internal/lsp: handle nil pointer in PackageStats Fixes golang/go#40224 Change-Id: I9f3f194b1c115ff0242cbce89a36e20d9e21a41f Reviewed-on: https://go-review.googlesource.com/c/tools/+/242797 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Heschi Kreinick --- internal/lsp/cache/cache.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/lsp/cache/cache.go b/internal/lsp/cache/cache.go index c9fa616848..be6cd91695 100644 --- a/internal/lsp/cache/cache.go +++ b/internal/lsp/cache/cache.go @@ -236,6 +236,9 @@ func (c *Cache) PackageStats(withNames bool) template.HTML { } func astCost(f *ast.File) int64 { + if f == nil { + return 0 + } var count int64 ast.Inspect(f, func(n ast.Node) bool { count += 32 // nodes are pretty small.