1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:04:43 -07:00

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 <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rebecca Stambler 2019-03-26 19:48:42 -04:00
parent c02eab13f0
commit cd3f3f06fc

View File

@ -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)