Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cue: limit number of position errors
Browse files Browse the repository at this point in the history
Retrieving locations of possible errors does not
do cycle checking. Limit number of positions
to avoid getting a stack overflow.

Fixes #269.

Change-Id: Ibd297eeae64386e557a864577b141d2dc8c62dab
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4840
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
  • Loading branch information
mpvl committed Jan 30, 2020
1 parent 0a6f7c9 commit 1ffc615
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cmd/cue/cmd/testdata/script/issue269.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
! cue eval ./struct.cue
cmp stderr expect-stderr
-- struct.cue --
type :: {
x: 0
y: 0

if x == 0 {i: 0}
if y == 0 {j: 0}
}

data: {
a: type
b: type

b: x: a.x
a: y: b.y
}
-- expect-stderr --
data.a: conflicting values 0 and a.x (mismatched types int and struct):
./struct.cue:2:8
./struct.cue:13:11
data.b: conflicting values 0 and a.x (mismatched types int and struct):
./struct.cue:2:8
./struct.cue:13:11
3 changes: 3 additions & 0 deletions cue/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ func (x *bottom) Positions(ctx *context) []token.Pos {
}

func appendPositions(ctx *context, pos []token.Pos, src source) []token.Pos {
if len(pos) > 15 {
return pos
}
if src != nil {
if p := src.Pos(); p != token.NoPos {
pos = append(pos, src.Pos())
Expand Down

0 comments on commit 1ffc615

Please sign in to comment.