From 13e2db7670d890b63c9e240f56b9037cb015bad0 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 8 Sep 2023 15:24:25 -0700 Subject: [PATCH] sourcebundle: Avoid infinite recursion with diagnosticInSourcePackage This wrapper type acts as an adapter to rewrite relative source paths in diagnostics to be absolute source addresses instead, but it was incorrectly calling its own Source method to get the starting value, rather than calling that of its wrapped diagnostic, thereby causing infinite recursion until stack overflow. --- sourcebundle/diagnostics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sourcebundle/diagnostics.go b/sourcebundle/diagnostics.go index df2b932..52fbc05 100644 --- a/sourcebundle/diagnostics.go +++ b/sourcebundle/diagnostics.go @@ -128,7 +128,7 @@ func (diag diagnosticInSourcePackage) Severity() DiagSeverity { } func (diag diagnosticInSourcePackage) Source() DiagSource { - ret := diag.Source() + ret := diag.wrapped.Source() if ret.Subject != nil && sourceaddrs.ValidSubPath(ret.Subject.Filename) { newRng := *ret.Subject // shallow copy newRng.Filename = diag.pkg.SourceAddr(newRng.Filename).String()