Handshake events null pointer fix

The mechanism is instanciated during the handshake itself, when and
error happen before this, the error method shall work anyway.
An error handling with a NULL mechanism means the handshake fail, so the
handshake failure event is also raised in this case.
This commit is contained in:
Vincent Tellier 2017-01-01 17:54:17 +01:00
parent ffb31dcadd
commit 7e36db07b1

View File

@ -978,7 +978,7 @@ void zmq::stream_engine_t::error (error_reason_t reason)
}
zmq_assert (session);
#ifdef ZMQ_BUILD_DRAFT_API
if(mechanism->status() == mechanism_t::handshaking)
if(mechanism == NULL || mechanism->status() == mechanism_t::handshaking)
socket->event_handshake_failed(endpoint, (int) s);
#endif
socket->event_disconnected (endpoint, (int) s);