mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Fix TableVal::DoClone to use CloneState cache
This commit is contained in:
parent
61d19d25e1
commit
aefd9322fd
6 changed files with 38 additions and 13 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
|||
|
||||
2.6-479 | 2019-06-20 18:31:58 -0700
|
||||
|
||||
* Fix TableVal::DoClone to use CloneState cache (Jon Siwek, Corelight)
|
||||
|
||||
2.6-478 | 2019-06-20 14:19:11 -0700
|
||||
|
||||
* Remove old Broccoli SSL options (Jon Siwek, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.6-478
|
||||
2.6-479
|
||||
|
|
|
@ -2181,7 +2181,7 @@ Val* TableVal::DoClone(CloneState* state)
|
|||
TableEntryVal* val;
|
||||
while ( (val = tbl->NextEntry(key, cookie)) )
|
||||
{
|
||||
TableEntryVal* nval = val->Clone();
|
||||
TableEntryVal* nval = val->Clone(state);
|
||||
tv->AsNonConstTable()->Insert(key, nval);
|
||||
|
||||
if ( subnets )
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#ifndef val_h
|
||||
#define val_h
|
||||
|
||||
// BRO values.
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <array>
|
||||
|
@ -374,6 +372,7 @@ protected:
|
|||
friend class RecordVal;
|
||||
friend class VectorVal;
|
||||
friend class ValManager;
|
||||
friend class TableEntryVal;
|
||||
|
||||
virtual void ValDescribe(ODesc* d) const;
|
||||
virtual void ValDescribeReST(ODesc* d) const;
|
||||
|
@ -804,9 +803,9 @@ public:
|
|||
int(network_time - bro_start_network_time);
|
||||
}
|
||||
|
||||
TableEntryVal* Clone()
|
||||
TableEntryVal* Clone(Val::CloneState* state)
|
||||
{
|
||||
auto rval = new TableEntryVal(val ? val->Clone() : nullptr);
|
||||
auto rval = new TableEntryVal(val ? val->Clone(state) : nullptr);
|
||||
rval->last_access_time = last_access_time;
|
||||
rval->expire_access_time = expire_access_time;
|
||||
rval->last_read_update = last_read_update;
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
direct assignment (PASS)
|
||||
using copy (PASS)
|
||||
F, T
|
||||
F, T
|
||||
[a=42], [a=42], [a=42], [a=42]
|
||||
|
|
|
@ -6,10 +6,8 @@ function test_case(msg: string, expect: bool)
|
|||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
||||
}
|
||||
|
||||
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
{
|
||||
# "b" is not a copy of "a"
|
||||
local a: set[string] = set("this", "test");
|
||||
local b: set[string] = a;
|
||||
|
@ -25,6 +23,27 @@ event zeek_init()
|
|||
delete c["this"];
|
||||
|
||||
test_case( "using copy", |d| == 2 && "this" in d);
|
||||
}
|
||||
|
||||
}
|
||||
type myrec: record {
|
||||
a: count;
|
||||
};
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
local v: vector of myrec;
|
||||
local t: table[count] of myrec;
|
||||
local mr = myrec($a = 42);
|
||||
|
||||
t[0] = mr;
|
||||
t[1] = mr;
|
||||
local tc = copy(t);
|
||||
print same_object(t, tc), same_object(tc[0], tc[1]);
|
||||
|
||||
v[0] = mr;
|
||||
v[1] = mr;
|
||||
local vc = copy(v);
|
||||
print same_object(v, vc), same_object(vc[0], vc[1]);
|
||||
print tc[0], tc[1], vc[0], vc[1];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue