summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander <akutsan@luxoft.com>2018-09-08 15:36:22 +0300
committerAndriy Byzhynar <abyzhynar@luxoft.com>2018-09-17 17:00:17 +0300
commit909a0885d7d9e6fa8ce2bd7ba2dfdf1e38600de8 (patch)
tree754fbf8fab11db56b3752792ad506c46683f4dd2
parent172824238c61d8e17effb972d612536eb2a6b581 (diff)
downloadsdl_core-909a0885d7d9e6fa8ce2bd7ba2dfdf1e38600de8.tar.gz
Fix using invalit iterator
Iterator of vector invalidates after eraze
-rw-r--r--src/components/hmi_message_handler/src/mb_controller.cc6
-rw-r--r--src/components/hmi_message_handler/src/websocket_session.cc2
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<std::shared_ptr<hmi_message_handler::WebsocketSession> >::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_);
}