mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 11:08:20 +00:00
Fix special-case-bug for vectors in UnaryExpr.
In some cases one can get the Type() of unaryexpr to be ANY. Vectors so far did not deal gracefully with this and crashed because trying to convert any to a vectortype. This patch fixes this by just using the original vector-type in this case.
This commit is contained in:
parent
da58f9d4a6
commit
12add53131
2 changed files with 26 additions and 1 deletions
|
@ -456,7 +456,13 @@ Val* UnaryExpr::Eval(Frame* f) const
|
|||
if ( is_vector(v) )
|
||||
{
|
||||
VectorVal* v_op = v->AsVectorVal();
|
||||
VectorVal* result = new VectorVal(Type()->AsVectorType());
|
||||
VectorType* out_t;
|
||||
if ( Type()->Tag() == TYPE_ANY )
|
||||
out_t = v->Type()->AsVectorType();
|
||||
else
|
||||
out_t = Type()->AsVectorType();
|
||||
|
||||
VectorVal* result = new VectorVal(out_t);
|
||||
|
||||
for ( unsigned int i = 0; i < v_op->Size(); ++i )
|
||||
{
|
||||
|
|
19
testing/btest/core/vector-assignment.bro
Normal file
19
testing/btest/core/vector-assignment.bro
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
# This regression test checks a special case in the vector code. In this case
|
||||
# UnaryExpr will be called with a Type() of any. Tests succeeds if it does not
|
||||
# crash Bro.
|
||||
|
||||
type OptionCacheValue: record {
|
||||
val: any;
|
||||
};
|
||||
|
||||
function set_me(val: any) {
|
||||
local a = OptionCacheValue($val=val);
|
||||
print a;
|
||||
}
|
||||
|
||||
event bro_init() {
|
||||
local b: vector of count = {1, 2, 3};
|
||||
set_me(b);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue