diff --git a/src/ebusd/network.cpp b/src/ebusd/network.cpp index d77f3e77..5a42e8bc 100644 --- a/src/ebusd/network.cpp +++ b/src/ebusd/network.cpp @@ -291,13 +291,15 @@ void Network::run() { } void Network::cleanConnections() { - list::iterator c_it; - for (c_it = m_connections.begin(); c_it != m_connections.end(); c_it++) { + list::iterator c_it = m_connections.begin(); + while (c_it != m_connections.end()) { if (!(*c_it)->isRunning()) { Connection* connection = *c_it; c_it = m_connections.erase(c_it); delete connection; logDebug(lf_network, "dead connection removed - %d", m_connections.size()); + } else { + c_it++; } } }