From 959a133520dfc80d29e83aa7ef762e1d0327f63b Mon Sep 17 00:00:00 2001 From: Thomas <89665709+ThomasRubin@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:21:46 +0100 Subject: [PATCH] Fixing SEGV #4524. Pipe should only send to peer when active. (#4647) * Fixing SEGV #4524. Pipe should only send to peer when active. --- src/pipe.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pipe.cpp b/src/pipe.cpp index 20caf5ba..181fe878 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -539,7 +539,8 @@ bool zmq::pipe_t::check_hwm () const void zmq::pipe_t::send_hwms_to_peer (int inhwm_, int outhwm_) { - send_pipe_hwm (_peer, inhwm_, outhwm_); + if (_state == active) + send_pipe_hwm (_peer, inhwm_, outhwm_); } void zmq::pipe_t::set_endpoint_pair (zmq::endpoint_uri_pair_t endpoint_pair_) @@ -554,10 +555,12 @@ const zmq::endpoint_uri_pair_t &zmq::pipe_t::get_endpoint_pair () const void zmq::pipe_t::send_stats_to_peer (own_t *socket_base_) { - endpoint_uri_pair_t *ep = - new (std::nothrow) endpoint_uri_pair_t (_endpoint_pair); - send_pipe_peer_stats (_peer, _msgs_written - _peers_msgs_read, socket_base_, - ep); + if (_state == active) { + endpoint_uri_pair_t *ep = + new (std::nothrow) endpoint_uri_pair_t (_endpoint_pair); + send_pipe_peer_stats (_peer, _msgs_written - _peers_msgs_read, + socket_base_, ep); + } } void zmq::pipe_t::process_pipe_peer_stats (uint64_t queue_count_,