From a266777d826f1b48b25557fb9bdbd43fac4e6eec Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 13 Feb 2018 17:51:20 -0800 Subject: [PATCH] destroyAllChannels() swap out channels list avoid possible modifications while iterating. --- src/remote/codec.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/remote/codec.cpp b/src/remote/codec.cpp index a8f1021..d252cea 100644 --- a/src/remote/codec.cpp +++ b/src/remote/codec.cpp @@ -1586,11 +1586,11 @@ void BlockingServerTCPTransportCodec::destroyAllChannels() { _socketName.c_str(), _channels.size()); } - _channels_t::iterator it(_channels.begin()); - for(; it!=_channels.end(); it++) - it->second->destroy(); + _channels_t temp; + temp.swap(_channels); - _channels.clear(); + for(_channels_t::iterator it(temp.begin()), end(temp.end()); it!=end; ++it) + it->second->destroy(); } void BlockingServerTCPTransportCodec::internalClose(bool force) {