this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue: always check that ParseExpr doesn't panic in the fuzzer

I just realised that we should check it doesn't panic in all cases,
and not just in those where ParseFile reports an error.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I17bb455bb4c90c420fe2dbcc07fdc8e8b423e1fc
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1235292
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+4 -2
+4 -2
cue/fuzz_test.go
··· 83 83 t.Skip() // keep inputs reasonably small for now 84 84 } 85 85 f, err := parser.ParseFile("fuzz.cue", s, parser.ParseComments) 86 - 86 + // Check ParseExpr too. Note that a valid file is not always a valid expression, 87 + // but we still want to check that ParseExpr doesn't panic. 88 + _, exprErr := parser.ParseExpr("fuzz.cue", s, parser.ParseComments) 87 89 if err != nil { 88 - if _, err := parser.ParseExpr("fuzz.cue", s, parser.ParseComments); err == nil { 90 + if exprErr == nil { 89 91 t.Errorf("ParseFile rejects this input but ParseExpr does not: %s", s) 90 92 } 91 93 if ast.IsValidIdent(s) {