From 36215656eb586a505d051dd60500e92d0f710f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Staffan=20Gim=C3=A5ker?= Date: Mon, 9 Jan 2012 12:19:59 +0100 Subject: [PATCH] Throw away unexpected data received by XPUB sockets, rather than asserting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes LIBZMQ-310. Signed-off-by: Staffan Gimåker --- src/xpub.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/xpub.cpp b/src/xpub.cpp index 5d7a97c4..1ad01457 100644 --- a/src/xpub.cpp +++ b/src/xpub.cpp @@ -63,18 +63,19 @@ void zmq::xpub_t::xread_activated (pipe_t *pipe_) // Apply the subscription to the trie. unsigned char *data = (unsigned char*) sub.data (); size_t size = sub.size (); - zmq_assert (size > 0 && (*data == 0 || *data == 1)); - bool unique; - if (*data == 0) - unique = subscriptions.rm (data + 1, size - 1, pipe_); - else - unique = subscriptions.add (data + 1, size - 1, pipe_); + if (size > 0 && (*data == 0 || *data == 1)) { + bool unique; + if (*data == 0) + unique = subscriptions.rm (data + 1, size - 1, pipe_); + else + unique = subscriptions.add (data + 1, size - 1, pipe_); - // If the subscription is not a duplicate store it so that it can be - // passed to used on next recv call. - if (unique && options.type != ZMQ_PUB) - pending.push_back (blob_t ((unsigned char*) sub.data (), - sub.size ())); + // If the subscription is not a duplicate store it so that it can be + // passed to used on next recv call. + if (unique && options.type != ZMQ_PUB) + pending.push_back (blob_t ((unsigned char*) sub.data (), + sub.size ())); + } } }