Commit 14a7edc7 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'jv-add-missing-bounds-checks' into 'master'

Add missing bounds checks in LSIF parser

See merge request gitlab-org/gitlab-workhorse!527
parents 027c123a c1fe1201
...@@ -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