mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix segfault when incrementing whole vector values.
Also removed RefExpr::Eval(Val*) method since it was never called (Clang emitted warning about this hiding overloaded virtual function UnaryExpr::Eval(Frame*)) and doesn't appear to be necessary even if it was called to avoid the default vector handling of UnaryExpr::Eval (as the comment suggests as the intention).
This commit is contained in:
parent
8279de25c9
commit
353393f9bd
5 changed files with 67 additions and 11 deletions
|
@ -1035,12 +1035,10 @@ Val* IncrExpr::Eval(Frame* f) const
|
||||||
{
|
{
|
||||||
Val* new_elt = DoSingleEval(f, elt);
|
Val* new_elt = DoSingleEval(f, elt);
|
||||||
v_vec->Assign(i, new_elt, this, OP_INCR);
|
v_vec->Assign(i, new_elt, this, OP_INCR);
|
||||||
Unref(new_elt); // was Ref()'d by Assign()
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
v_vec->Assign(i, 0, this, OP_INCR);
|
v_vec->Assign(i, 0, this, OP_INCR);
|
||||||
}
|
}
|
||||||
// FIXME: Is the next line needed?
|
|
||||||
op->Assign(f, v_vec, OP_INCR);
|
op->Assign(f, v_vec, OP_INCR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2402,11 +2400,6 @@ Expr* RefExpr::MakeLvalue()
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* RefExpr::Eval(Val* v) const
|
|
||||||
{
|
|
||||||
return Fold(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefExpr::Assign(Frame* f, Val* v, Opcode opcode)
|
void RefExpr::Assign(Frame* f, Val* v, Opcode opcode)
|
||||||
{
|
{
|
||||||
op->Assign(f, v, opcode);
|
op->Assign(f, v, opcode);
|
||||||
|
|
|
@ -608,10 +608,6 @@ public:
|
||||||
void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN);
|
void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN);
|
||||||
Expr* MakeLvalue();
|
Expr* MakeLvalue();
|
||||||
|
|
||||||
// Only overridden to avoid special vector handling which doesn't apply
|
|
||||||
// for this class.
|
|
||||||
Val* Eval(Val* v) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Expr;
|
friend class Expr;
|
||||||
RefExpr() { }
|
RefExpr() { }
|
||||||
|
|
5
testing/btest/Baseline/language.incr-vec-expr/out
Normal file
5
testing/btest/Baseline/language.incr-vec-expr/out
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[0, 0, 0]
|
||||||
|
[a=0, b=test, c=[1, 2, 3]]
|
||||||
|
[1, 1, 1]
|
||||||
|
[a=1, b=test, c=[1, 2, 3]]
|
||||||
|
[a=1, b=test, c=[2, 3, 4]]
|
35
testing/btest/core/leaks/incr-vec-expr.test
Normal file
35
testing/btest/core/leaks/incr-vec-expr.test
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# Needs perftools support.
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: bro --help 2>&1 | grep -q mem-leaks
|
||||||
|
#
|
||||||
|
# @TEST-GROUP: leaks
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local bro -b -m -r $TRACES/chksums/ip4-udp-good-chksum.pcap %INPUT
|
||||||
|
|
||||||
|
type rec: record {
|
||||||
|
a: count;
|
||||||
|
b: string;
|
||||||
|
c: vector of count;
|
||||||
|
};
|
||||||
|
|
||||||
|
global vec: vector of count = vector(0,0,0);
|
||||||
|
|
||||||
|
global v: rec = [$a=0, $b="test", $c=vector(1,2,3)];
|
||||||
|
|
||||||
|
event new_connection(c: connection)
|
||||||
|
{
|
||||||
|
print vec;
|
||||||
|
print v;
|
||||||
|
|
||||||
|
++vec;
|
||||||
|
|
||||||
|
print vec;
|
||||||
|
|
||||||
|
++v$a;
|
||||||
|
|
||||||
|
print v;
|
||||||
|
|
||||||
|
++v$c;
|
||||||
|
|
||||||
|
print v;
|
||||||
|
}
|
27
testing/btest/language/incr-vec-expr.test
Normal file
27
testing/btest/language/incr-vec-expr.test
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# @TEST-EXEC: bro -b %INPUT >out
|
||||||
|
# @TEST-EXEC: btest-diff out
|
||||||
|
|
||||||
|
type rec: record {
|
||||||
|
a: count;
|
||||||
|
b: string;
|
||||||
|
c: vector of count;
|
||||||
|
};
|
||||||
|
|
||||||
|
global vec: vector of count = vector(0,0,0);
|
||||||
|
|
||||||
|
global v: rec = [$a=0, $b="test", $c=vector(1,2,3)];
|
||||||
|
|
||||||
|
print vec;
|
||||||
|
print v;
|
||||||
|
|
||||||
|
++vec;
|
||||||
|
|
||||||
|
print vec;
|
||||||
|
|
||||||
|
++v$a;
|
||||||
|
|
||||||
|
print v;
|
||||||
|
|
||||||
|
++v$c;
|
||||||
|
|
||||||
|
print v;
|
Loading…
Add table
Add a link
Reference in a new issue