From 412790c7ba9c227c1727d2c2b2fbde5a644f97f9 Mon Sep 17 00:00:00 2001 From: Samaresh Kumar Singh Date: Fri, 17 Apr 2026 18:28:56 -0500 Subject: [PATCH] fix double free in pipe_t::process_pipe_term_ack --- src/pipe.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pipe.cpp b/src/pipe.cpp index 181fe87832..e89a98e6c1 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -359,16 +359,18 @@ void zmq::pipe_t::process_pipe_term_ack () // First, delete all the unread messages in the pipe. We have to do it by // hand because msg_t doesn't have automatic destructor. Then deallocate // the ypipe itself. + upipe_t *const in_pipe = _in_pipe; + _in_pipe = NULL; - if (!_conflate) { + if (!_conflate && in_pipe) { msg_t msg; - while (_in_pipe->read (&msg)) { + while (in_pipe->read (&msg)) { const int rc = msg.close (); errno_assert (rc == 0); } } - LIBZMQ_DELETE (_in_pipe); + delete in_pipe; // Deallocate the pipe object delete this;