mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
GH-1672: Keep a reference to a table being expired, just in case
This commit is contained in:
parent
8184073ef8
commit
b8ca68f548
1 changed files with 13 additions and 1 deletions
14
src/Val.cc
14
src/Val.cc
|
@ -1359,15 +1359,27 @@ TableValTimer::TableValTimer(TableVal* val, double t) : detail::Timer(t, detail:
|
|||
|
||||
TableValTimer::~TableValTimer()
|
||||
{
|
||||
table->ClearTimer(this);
|
||||
if ( table )
|
||||
table->ClearTimer(this);
|
||||
}
|
||||
|
||||
void TableValTimer::Dispatch(double t, bool is_expire)
|
||||
{
|
||||
if ( ! is_expire )
|
||||
{
|
||||
// Take this reference in case the expiration does something silly like resetting the
|
||||
// table object itself. Doing so would cause a crash since the method would try to
|
||||
// delete the table while it was being actively used.
|
||||
TableValPtr temp = {NewRef{}, table};
|
||||
|
||||
table->ClearTimer(this);
|
||||
table->DoExpire(t);
|
||||
|
||||
// If the table did get deleted earlier, then the only existing reference will be the
|
||||
// one taken above. In that case, set table to nullptr here so ~TableValTimer doesn't
|
||||
// also try to do something with it.
|
||||
if ( table->RefCnt() == 1 )
|
||||
table = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue