From 62bab7d28055a8c53fb149935cfb1fc7a6b5d1f8 Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 22 Apr 2017 11:33:37 +0200 Subject: [PATCH] fix for potentially skipped entries in cleanConnections() --- src/ebusd/network.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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++; } } }