1
0
mirror of https://github.com/golang/go synced 2024-11-26 03:47:57 -07:00

cmd/go: fix infinite loop in modload.keepSums

Fixes #42891

Change-Id: I0cce4204a1c4959b896188a2ab3719c0507f95e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/274172
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Jay Conrod 2020-11-30 15:46:33 -05:00
parent 4f42a9b76b
commit d2b436d95d
2 changed files with 15 additions and 1 deletions

View File

@ -1018,7 +1018,7 @@ func keepSums(addDirect bool) map[module.Version]bool {
}
}
for _, pkg := range loaded.pkgs {
if pkg.testOf != nil || pkg.inStd {
if pkg.testOf != nil || pkg.inStd || module.CheckImportPath(pkg.path) != nil {
continue
}
for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) {

View File

@ -0,0 +1,14 @@
# If an import declaration is an absolute path, most commands should report
# an error instead of going into an infinite loop.
# Verifies golang.org/issue/42891.
go list .
stdout '^m$'
-- go.mod --
module m
go 1.16
-- m.go --
package m
import "/"