Fix iterator invalidation in broker::Manager dtor.

This commit is contained in:
Jon Siwek 2015-04-13 10:34:42 -05:00
parent 8bd38c2788
commit 63ab936d8c
3 changed files with 15 additions and 3 deletions

View file

@ -26,8 +26,15 @@ int bro_broker::Manager::send_flags_unsolicited_idx;
bro_broker::Manager::~Manager()
{
vector<decltype(data_stores)::key_type> stores_to_close;
for ( auto& s : data_stores )
CloseStore(s.first.first, s.first.second);
stores_to_close.emplace_back(s.first);
for ( auto& s : stores_to_close )
// This doesn't loop directly over data_stores, because CloseStore
// modifies the map and invalidates iterators.
CloseStore(s.first, s.second);
}
static int require_field(RecordType* rt, const char* name)