fix crash: do NOT erase an element without changing the iterator in looping a STL container