zeromq / zmqpp

0mq 'highlevel' C++ bindings
http://zeromq.github.io/zmqpp
Mozilla Public License 2.0
439 stars 195 forks source link

context move assignment operator leaks context #23

Closed cneumann closed 10 years ago

cneumann commented 10 years ago
context& operator=(context&& source) noexcept
{
    _context = source._context;
    source._context = nullptr;
    return *this;
}

In the above _context is overwritten without being released. How about just doing std::swap(_context, source._context)? That way the _context will be cleaned up by the dtor of source.

benjamg commented 10 years ago

Good catch, I assume I just copied from the move constructor (where the local context would have been null anyway) and didn't notice how broken that was.

cneumann commented 10 years ago

Thanks for the quick fix! It's probably much more important that you fixed the equivalent issue for the socket move assignment operator, but I was actually referring to the one of the context class, which still has the problem I think ;)