mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
fix for cloning records with fields of type "any"
This commit is contained in:
parent
cd8e16e090
commit
099dc99d2b
2 changed files with 8 additions and 5 deletions
|
@ -2936,7 +2936,8 @@ void RecordVal::ResizeParseTimeRecords(RecordType* revised_rt)
|
|||
if ( required_length > current_length )
|
||||
{
|
||||
for ( auto i = current_length; i < required_length; ++i )
|
||||
rv->AppendField(revised_rt->FieldDefault(i));
|
||||
rv->AppendField(revised_rt->FieldDefault(i),
|
||||
revised_rt->GetFieldType(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3123,7 +3124,7 @@ ValPtr RecordVal::DoClone(CloneState* state)
|
|||
{
|
||||
auto f_i = GetField(i);
|
||||
auto v = f_i ? f_i->Clone(state) : nullptr;
|
||||
rv->AppendField(std::move(v));
|
||||
rv->AppendField(std::move(v), rt->GetFieldType(i));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -1176,13 +1176,15 @@ public:
|
|||
/**
|
||||
* Appends a value to the record's fields. The caller is responsible
|
||||
* for ensuring that fields are appended in the correct order and
|
||||
* with the correct type.
|
||||
* with the correct type. The type needs to be passed in because
|
||||
* it's unsafe to take it from v when the field's type is "any" while
|
||||
* v is a concrete type.
|
||||
* @param v The value to append.
|
||||
*/
|
||||
void AppendField(ValPtr v)
|
||||
void AppendField(ValPtr v, const TypePtr& t)
|
||||
{
|
||||
if ( v )
|
||||
record_val->emplace_back(ZVal(v, v->GetType()));
|
||||
record_val->emplace_back(ZVal(v, t));
|
||||
else
|
||||
record_val->emplace_back(std::nullopt);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue