diff --git a/src/Type.cc b/src/Type.cc index 80a6e9c678..9c0f22d868 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1326,10 +1326,15 @@ void RecordType::DescribeFields(ODesc* d) const d->AddCount(types->length()); for ( const auto& type : *types ) { - type->type->Describe(d); - d->SP(); d->Add(type->id); d->SP(); + + if ( d->FindType(type->type.get()) ) + d->Add(""); + else + type->type->Describe(d); + + d->SP(); } } } diff --git a/testing/btest/core/recursive-types.zeek b/testing/btest/core/recursive-types.zeek new file mode 100644 index 0000000000..c4f6f595e1 --- /dev/null +++ b/testing/btest/core/recursive-types.zeek @@ -0,0 +1,22 @@ +# @TEST-EXEC: zeek -b %INPUT + +# global_ids() here contains some types that are recursive, in that +# arguments to functions contain chained references to the type that +# defines the function. This tests that we don't crash when +# attempting to call Describe() on those types in binary-mode. +event zeek_init() + { + local sh: string = ""; + local gi = global_ids(); + for (myfunc in gi) + { + if(gi[myfunc]?$value) + { + if(strstr(myfunc,"lambda") > 0) + { + sh = sha256_hash(gi[myfunc]$value); + print(sh); + } + } + } + }