Commit c1fe1201 authored by Jacob Vosmaer's avatar Jacob Vosmaer Committed by Nick Thomas

Add missing bounds checks in LSIF parser

parent 027c123a
...@@ -14,7 +14,7 @@ const ( ...@@ -14,7 +14,7 @@ const (
type Id int32 type Id int32
func (id *Id) UnmarshalJSON(b []byte) error { func (id *Id) UnmarshalJSON(b []byte) error {
if b[0] != '"' { if len(b) > 0 && b[0] != '"' {
if err := id.unmarshalInt(b); err != nil { if err := id.unmarshalInt(b); err != nil {
return err return err
} }
......
...@@ -2,6 +2,7 @@ package parser ...@@ -2,6 +2,7 @@ package parser
import ( import (
"encoding/json" "encoding/json"
"errors"
"io" "io"
"strconv" "strconv"
) )
...@@ -177,6 +178,10 @@ func (r *Ranges) addItem(line []byte) error { ...@@ -177,6 +178,10 @@ func (r *Ranges) addItem(line []byte) error {
} }
func (r *Ranges) addDefRef(defRef *RawDefRef) error { func (r *Ranges) addDefRef(defRef *RawDefRef) error {
if len(defRef.RangeIds) == 0 {
return errors.New("no range IDs")
}
var rg Range var rg Range
if err := r.Cache.Entry(defRef.RangeIds[0], &rg); err != nil { if err := r.Cache.Entry(defRef.RangeIds[0], &rg); err != nil {
return err return err
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment