Commit a9aeb492 authored by Luca Boccassi's avatar Luca Boccassi

Problem: Valgrind reports read of freed memory

Solution: when iterating over a map and conditionally deleting
elements, an erased iterator gets invalidated. Call erase using postfix
increment on iterator to avoid using an invalid element in the next
iteration.
parent c5bf0dc0
...@@ -99,9 +99,11 @@ void zmq::radio_t::xwrite_activated (pipe_t *pipe_) ...@@ -99,9 +99,11 @@ void zmq::radio_t::xwrite_activated (pipe_t *pipe_)
void zmq::radio_t::xpipe_terminated (pipe_t *pipe_) void zmq::radio_t::xpipe_terminated (pipe_t *pipe_)
{ {
for (subscriptions_t::iterator it = subscriptions.begin (); it != subscriptions.end (); ++it) { for (subscriptions_t::iterator it = subscriptions.begin (); it != subscriptions.end (); ) {
if (it->second == pipe_) { if (it->second == pipe_) {
subscriptions.erase (it); subscriptions.erase (it++);
} else {
++it;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment