0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-26 23:01:04 +08:00

Merge pull request #3935 from bluca/fuzzers

Problem: small memory leaks in PUB/XPUB
This commit is contained in:
Doron Somech 2020-05-25 19:45:54 +03:00 committed by GitHub
commit c95f7d0933
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,11 @@ zmq::xpub_t::xpub_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
zmq::xpub_t::~xpub_t ()
{
_welcome_msg.close ();
for (std::deque<metadata_t *>::iterator it = _pending_metadata.begin (),
end = _pending_metadata.end ();
it != end; ++it)
if (*it && (*it)->drop_ref ())
LIBZMQ_DELETE (*it);
}
void zmq::xpub_t::xattach_pipe (pipe_t *pipe_,
@ -126,8 +131,10 @@ void zmq::xpub_t::xread_activated (pipe_t *pipe_)
_process_subscribe =
!_only_first_subscribe || is_subscribe_or_cancel;
if (!is_subscribe_or_cancel) {
// Process user message coming upstream from xsub socket
if (!is_subscribe_or_cancel && options.type != ZMQ_PUB) {
// Process user message coming upstream from xsub socket,
// but not if the type is PUB, which never processes user
// messages
_pending_data.push_back (blob_t (msg_data, msg.size ()));
if (metadata)
metadata->add_ref ();