From 023b34a14493f21f2c25994b4370d7fb19694400 Mon Sep 17 00:00:00 2001 From: Eric Camachat Date: Sat, 2 Apr 2016 09:08:40 -0700 Subject: [PATCH] Fix issue #1419 segfault when using a XSUB/XPUB proxy. Ref. https://github.com/zeromq/libzmq/issues/1419 --- src/dist.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dist.cpp b/src/dist.cpp index 688aa57faa..6c8dbe7a93 100644 --- a/src/dist.cpp +++ b/src/dist.cpp @@ -124,12 +124,14 @@ void zmq::dist_t::pipe_terminated (pipe_t *pipe_) void zmq::dist_t::activated (pipe_t *pipe_) { // Move the pipe from passive to eligible state. - pipes.swap (pipes.index (pipe_), eligible); - eligible++; + if (eligible < pipes.size ()) { + pipes.swap (pipes.index (pipe_), eligible); + eligible++; + } // If there's no message being sent at the moment, move it to // the active state. - if (!more) { + if (!more && active < pipes.size ()) { pipes.swap (eligible - 1, active); active++; }