mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Stmt: Fix assert evaluating cond twice
Since 81a9745fb3
, the assert condition is
evaluated twice. This leads to unexpected behavior when cond has a side
effect like publishing a message or creating a log stream or filter.
Found while using the following in ad-hoc testing code and wondering
why two messages were published.
assert publish(Cluster::worker_topic, hello, "abc")
This commit is contained in:
parent
724daa2792
commit
6572324b8c
4 changed files with 36 additions and 1 deletions
|
@ -1644,7 +1644,7 @@ ValPtr AssertStmt::Exec(Frame* f, StmtFlowType& flow) {
|
|||
bool run_result_hook = assertion_result_hook && assertion_result_hook->HasEnabledBodies();
|
||||
auto assert_result = cond->Eval(f)->AsBool();
|
||||
|
||||
if ( ! cond->Eval(f)->AsBool() || run_result_hook ) {
|
||||
if ( ! assert_result || run_result_hook ) {
|
||||
zeek::StringValPtr msg_val = zeek::val_mgr->EmptyString();
|
||||
|
||||
if ( msg ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue