From cd3f3f06fc2d4af88acdfebc352e4cc2a8aeafe5 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Tue, 26 Mar 2019 19:48:42 -0400 Subject: [PATCH] internal/span: return error when on spans with invalid starts Fixes golang/go#30155 Change-Id: I7f9dbec6fdfa92654f58627ef44ee4bfe2870fa6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/169440 Run-TryBot: Rebecca Stambler Reviewed-by: Ian Cottrell TryBot-Result: Gobot Gobot --- internal/span/token.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/span/token.go b/internal/span/token.go index 324c258750..fb4d16d53b 100644 --- a/internal/span/token.go +++ b/internal/span/token.go @@ -65,6 +65,9 @@ func (r Range) Span() (Span, error) { return Span{}, fmt.Errorf("file not found in FileSet") } s := Span{v: span{URI: FileURI(f.Name())}} + if !r.Start.IsValid() { + return Span{}, fmt.Errorf("invalid position for start of range") + } s.v.Start.Offset = f.Offset(r.Start) if r.End.IsValid() { s.v.End.Offset = f.Offset(r.End)