Skip to content

Commit 412790c

Browse files
committed
fix double free in pipe_t::process_pipe_term_ack
1 parent b946c18 commit 412790c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/pipe.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,18 @@ void zmq::pipe_t::process_pipe_term_ack ()
359359
// First, delete all the unread messages in the pipe. We have to do it by
360360
// hand because msg_t doesn't have automatic destructor. Then deallocate
361361
// the ypipe itself.
362+
upipe_t *const in_pipe = _in_pipe;
363+
_in_pipe = NULL;
362364

363-
if (!_conflate) {
365+
if (!_conflate && in_pipe) {
364366
msg_t msg;
365-
while (_in_pipe->read (&msg)) {
367+
while (in_pipe->read (&msg)) {
366368
const int rc = msg.close ();
367369
errno_assert (rc == 0);
368370
}
369371
}
370372

371-
LIBZMQ_DELETE (_in_pipe);
373+
delete in_pipe;
372374

373375
// Deallocate the pipe object
374376
delete this;

0 commit comments

Comments
 (0)