Merge remote-tracking branch 'origin/topic/vern/vector-hole-loops'

* origin/topic/vern/vector-hole-loops:
  fix for looping over vectors with holes per https://github.com/zeek/zeek/issues/1763
  btest for https://github.com/zeek/zeek/issues/1763
This commit is contained in:
Tim Wojtulewicz 2021-09-08 12:04:45 -07:00
commit 8414d13030
5 changed files with 39 additions and 1 deletions

View file

@ -1349,9 +1349,13 @@ ValPtr ForStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow)
else if ( v->GetType()->Tag() == TYPE_VECTOR )
{
VectorVal* vv = v->AsVectorVal();
const auto& raw_vv = *vv->RawVec();
for ( auto i = 0u; i < vv->Size(); ++i )
{
if ( ! raw_vv[i] )
continue;
// Set the loop variable to the current index, and make
// another pass over the loop body.
f->SetElement((*loop_vars)[0], val_mgr->Count(i));