mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix ref-counting bug in EnumType copy ctor
Which was used by the new ShallowClone method and causes multiple enum declarations/definitions to now crash. Such code is not typically seen in scripts, but being able to define an enum in both .bif and .bro files has historically been supported.
This commit is contained in:
parent
50e4da74cf
commit
db5b73cb8a
3 changed files with 14 additions and 0 deletions
|
@ -1091,6 +1091,9 @@ EnumType::EnumType(const EnumType* e)
|
|||
names[it->first] = it->second;
|
||||
|
||||
vals = e->vals;
|
||||
|
||||
for ( auto& kv : vals )
|
||||
::Ref(kv.second);
|
||||
}
|
||||
|
||||
EnumType* EnumType::ShallowClone()
|
||||
|
|
1
testing/btest/Baseline/language.enum-multiple-decls/out
Normal file
1
testing/btest/Baseline/language.enum-multiple-decls/out
Normal file
|
@ -0,0 +1 @@
|
|||
ONE
|
10
testing/btest/language/enum-multiple-decls.zeek
Normal file
10
testing/btest/language/enum-multiple-decls.zeek
Normal file
|
@ -0,0 +1,10 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
# At the moment, it's legal to allow a double definitions. Internally, the
|
||||
# reason/comment is: "so that we can define an enum both in a *.bif and *.zeek
|
||||
# for avoiding cyclic dependencies."
|
||||
|
||||
type myenum: enum { ONE = 0x01 };
|
||||
type myenum: enum { ONE = 0x01 };
|
||||
print ONE;
|
Loading…
Add table
Add a link
Reference in a new issue