Skip to content

Commit

Permalink
pkg/compiler: fix infinite recursion on unions
Browse files Browse the repository at this point in the history
Found by go-fuzz on fuzzbuzz.
  • Loading branch information
dvyukov committed Mar 5, 2019
1 parent eb9e33b commit 78b7ec0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ func TestFuzz(t *testing.T) {
"da[",
"define\x98define(define\x98define\x98define\x98define\x98define)define\tdefin",
"resource g[g]",
`t[
l t
]`,
}
consts := map[string]uint64{"A": 1, "B": 2, "C": 3, "SYS_C": 4}
consts := map[string]uint64{"A": 1, "B": 2, "C": 3, "SYS_A": 4, "SYS_B": 5, "SYS_C": 6}
eh := func(pos ast.Pos, msg string) {
t.Logf("%v: %v", pos, msg)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/compiler/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func init() {
canBeArg := true
for _, fld := range s.Fields {
desc := comp.getTypeDesc(fld.Type)
if desc == nil || desc.CanBeArgRet == nil {
if desc == nil || desc == typeStruct || desc.CanBeArgRet == nil {
return false, false
}
canBeArg1, _ := desc.CanBeArgRet(comp, fld.Type)
Expand Down

0 comments on commit 78b7ec0

Please sign in to comment.