Problem: stream_engine_t instance may access its fields after it deleted itself

Solution: prevent access to data if the object was deleted
This commit is contained in:
Simon Giesecke
2018-08-09 13:17:21 +02:00
parent 05e400a3e0
commit 563651e0c9
11 changed files with 38 additions and 21 deletions

View File

@@ -441,7 +441,7 @@ void zmq::stream_engine_t::restart_output ()
out_event ();
}
void zmq::stream_engine_t::restart_input ()
bool zmq::stream_engine_t::restart_input ()
{
zmq_assert (_input_stopped);
zmq_assert (_session != NULL);
@@ -451,9 +451,11 @@ void zmq::stream_engine_t::restart_input ()
if (rc == -1) {
if (errno == EAGAIN)
_session->flush ();
else
else {
error (protocol_error);
return;
return false;
}
return true;
}
while (_insize > 0) {
@@ -471,10 +473,14 @@ void zmq::stream_engine_t::restart_input ()
if (rc == -1 && errno == EAGAIN)
_session->flush ();
else if (_io_error)
else if (_io_error) {
error (connection_error);
else if (rc == -1)
return false;
} else if (rc == -1) {
error (protocol_error);
return false;
}
else {
_input_stopped = false;
set_pollin (_handle);
@@ -483,6 +489,8 @@ void zmq::stream_engine_t::restart_input ()
// Speculative read.
in_event ();
}
return true;
}
bool zmq::stream_engine_t::handshake ()
@@ -814,7 +822,8 @@ void zmq::stream_engine_t::zap_msg_available ()
return;
}
if (_input_stopped)
restart_input ();
if (!restart_input ())
return;
if (_output_stopped)
restart_output ();
}