diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 68119ed28..d360d211f 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -433,14 +433,14 @@ void FGNasalSys::update(double) { if(_purgeListeners) { _purgeListeners = false; - map::reverse_iterator it, eit; - map::reverse_iterator end = _listener.rend(); - for(it = _listener.rbegin(); it != end; ) { - eit = it++; - FGNasalListener *nl = eit->second; + map::iterator it; + for ( it = _listener.begin(); it != _listener.end(); ) { + FGNasalListener *nl = it->second; if(nl->_dead) { - _listener.erase((++eit).base()); + _listener.erase( it++ ); delete nl; + } else { + ++it; } } }