Fix DNS script deleting a table element while iterating

Doesn't typically cause any problems since the loop breaks after
deleting, except there's now an assert in debug builds catching
potential problems like this.
This commit is contained in:
Jon Siwek 2020-08-06 20:48:08 -07:00 committed by Tim Wojtulewicz
parent f613cb0c68
commit fef4fda2f7

View file

@ -285,12 +285,19 @@ hook set_session(c: connection, msg: dns_msg, is_query: bool) &priority=5
else
{
# Just pick an arbitrary, unpaired query.
local tid: count;
local found_one = F;
for ( trans_id, q in c$dns_state$pending_queries )
if ( Queue::len(q) > 0 )
{
c$dns_state$pending_query = pop_msg(c$dns_state$pending_queries, trans_id);
tid = trans_id;
found_one = T;
break;
}
if ( found_one )
c$dns_state$pending_query = pop_msg(c$dns_state$pending_queries, tid);
}
}
}