mirror of
https://github.com/golang/go
synced 2024-11-26 03:27:58 -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:
parent
4f42a9b76b
commit
d2b436d95d
@ -1018,7 +1018,7 @@ func keepSums(addDirect bool) map[module.Version]bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, pkg := range loaded.pkgs {
|
for _, pkg := range loaded.pkgs {
|
||||||
if pkg.testOf != nil || pkg.inStd {
|
if pkg.testOf != nil || pkg.inStd || module.CheckImportPath(pkg.path) != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) {
|
for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) {
|
||||||
|
14
src/cmd/go/testdata/script/mod_import_issue42891.txt
vendored
Normal file
14
src/cmd/go/testdata/script/mod_import_issue42891.txt
vendored
Normal 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 "/"
|
Loading…
Reference in New Issue
Block a user