fix: avoid infinite loop when parsing recursive types

Mark all visited types as such when walking down struct fields.

Fixes #750.
Updates #652.
This commit is contained in:
Marc Vertes
2020-07-06 15:30:04 +02:00
committed by GitHub
parent 851444453c
commit 2a70a71dc2
2 changed files with 25 additions and 0 deletions

View File

@@ -1385,6 +1385,8 @@ func hasRecursiveStruct(t *itype, defined map[string]*itype) bool {
if defined[typ.path+"/"+typ.name] != nil {
return true
}
defined[typ.path+"/"+typ.name] = typ
for _, f := range typ.field {
if hasRecursiveStruct(f.typ, defined) {
return true