mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Add missing ShallowClone implementation for SetType
It turns out that SetType was missing a ShallowClone implementation. Which meant that when a SetType was cloned, a TableType was received (which has one less member). Which resulted in invalid memory accesses when using the clone. Thank you valgrind :)
This commit is contained in:
parent
5365d60202
commit
53cde131e9
2 changed files with 15 additions and 0 deletions
13
src/Type.cc
13
src/Type.cc
|
@ -484,6 +484,19 @@ SetType::SetType(TypeList* ind, ListExpr* arg_elements) : TableType(ind, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetType* SetType::ShallowClone()
|
||||||
|
{
|
||||||
|
// constructor only consumes indices when elements
|
||||||
|
// is set
|
||||||
|
if ( elements && indices )
|
||||||
|
{
|
||||||
|
elements->Ref();
|
||||||
|
indices->Ref();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SetType(indices, elements);
|
||||||
|
}
|
||||||
|
|
||||||
SetType::~SetType()
|
SetType::~SetType()
|
||||||
{
|
{
|
||||||
Unref(elements);
|
Unref(elements);
|
||||||
|
|
|
@ -381,6 +381,8 @@ public:
|
||||||
SetType(TypeList* ind, ListExpr* arg_elements);
|
SetType(TypeList* ind, ListExpr* arg_elements);
|
||||||
~SetType() override;
|
~SetType() override;
|
||||||
|
|
||||||
|
SetType* ShallowClone() override;
|
||||||
|
|
||||||
ListExpr* SetElements() const { return elements; }
|
ListExpr* SetElements() const { return elements; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue