Skip to content

Commit

Permalink
Fix race due unprotected access to callbacks_ in roscpp client (#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-semenov authored and dirk-thomas committed Aug 3, 2020
1 parent e331112 commit df09637
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clients/roscpp/src/libros/publication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ void Publication::dropAllConnections()

void Publication::peerConnect(const SubscriberLinkPtr& sub_link)
{
boost::mutex::scoped_lock lock(callbacks_mutex_);

V_Callback::iterator it = callbacks_.begin();
V_Callback::iterator end = callbacks_.end();
for (; it != end; ++it)
Expand All @@ -339,6 +341,8 @@ void Publication::peerConnect(const SubscriberLinkPtr& sub_link)

void Publication::peerDisconnect(const SubscriberLinkPtr& sub_link)
{
boost::mutex::scoped_lock lock(callbacks_mutex_);

V_Callback::iterator it = callbacks_.begin();
V_Callback::iterator end = callbacks_.end();
for (; it != end; ++it)
Expand Down

0 comments on commit df09637

Please sign in to comment.