Fix interator handling in ~TestFileStoreState(). After std::map::erase()
the used iterator is invalid. Use a while-loop and erase the object with
post-incremented iterator instead.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
}
~TestFileStoreState() {
map<int, coll_entry_t*>::iterator it = m_collections.begin();
- for (; it != m_collections.end(); it++) {
- if (it->second)
- delete it->second;
- m_collections.erase(it);
+ while (it != m_collections.end()) {
+ if (it->second)
+ delete it->second;
+ m_collections.erase(it++);
}
}