From 909a0885d7d9e6fa8ce2bd7ba2dfdf1e38600de8 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 8 Sep 2018 15:36:22 +0300 Subject: Fix using invalit iterator Iterator of vector invalidates after eraze --- src/components/hmi_message_handler/src/mb_controller.cc | 6 +++--- src/components/hmi_message_handler/src/websocket_session.cc | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/hmi_message_handler/src/mb_controller.cc b/src/components/hmi_message_handler/src/mb_controller.cc index 4f46026039..fbff4c47c7 100644 --- a/src/components/hmi_message_handler/src/mb_controller.cc +++ b/src/components/hmi_message_handler/src/mb_controller.cc @@ -220,9 +220,9 @@ void CMessageBrokerController::exitReceivingThread() { mConnectionListLock.Acquire(); std::vector >::iterator it; - for (it = mConnectionList.begin(); it != mConnectionList.end();) { - (*it)->Shutdown(); - it = mConnectionList.erase(it); + while(!mConnectionList.empty()){ + mConnectionList.back()->Shutdown(); + mConnectionList.pop_back(); } mConnectionListLock.Release(); diff --git a/src/components/hmi_message_handler/src/websocket_session.cc b/src/components/hmi_message_handler/src/websocket_session.cc index a148f48661..adad94dd13 100644 --- a/src/components/hmi_message_handler/src/websocket_session.cc +++ b/src/components/hmi_message_handler/src/websocket_session.cc @@ -60,9 +60,11 @@ void WebsocketSession::Accept() { void WebsocketSession::Shutdown() { shutdown_ = true; + DCHECK(thread_delegate_); thread_delegate_->SetShutdown(); thread_->join(); delete thread_delegate_; + thread_delegate_ = NULL; threads::DeleteThread(thread_); } -- cgit v1.2.1