mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 18:40:27 +01:00
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.
This commit is contained in:
parent
c5bf0dc0a4
commit
a9aeb492dc
@ -99,9 +99,11 @@ void zmq::radio_t::xwrite_activated (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_) {
|
||||
subscriptions.erase (it);
|
||||
subscriptions.erase (it++);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user