mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-09 23:36:04 +00:00
[LIBZMQ-450] Copy the stream engine endpoint - string reference caused memory corruption
This commit is contained in:
parent
bef9a41bdb
commit
fdf162a117
@ -63,7 +63,6 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_, cons
|
|||||||
greeting_bytes_read (0),
|
greeting_bytes_read (0),
|
||||||
session (NULL),
|
session (NULL),
|
||||||
options (options_),
|
options (options_),
|
||||||
endpoint (endpoint_),
|
|
||||||
plugged (false),
|
plugged (false),
|
||||||
socket (NULL)
|
socket (NULL)
|
||||||
{
|
{
|
||||||
@ -96,6 +95,8 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_, cons
|
|||||||
int rc = setsockopt (s, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof (int));
|
int rc = setsockopt (s, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof (int));
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
#endif
|
#endif
|
||||||
|
endpoint = new char[endpoint_.length() + 1];
|
||||||
|
strcpy (endpoint, endpoint_.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
zmq::stream_engine_t::~stream_engine_t ()
|
zmq::stream_engine_t::~stream_engine_t ()
|
||||||
@ -117,6 +118,7 @@ zmq::stream_engine_t::~stream_engine_t ()
|
|||||||
delete encoder;
|
delete encoder;
|
||||||
if (decoder != NULL)
|
if (decoder != NULL)
|
||||||
delete decoder;
|
delete decoder;
|
||||||
|
delete [] endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::stream_engine_t::plug (io_thread_t *io_thread_,
|
void zmq::stream_engine_t::plug (io_thread_t *io_thread_,
|
||||||
@ -484,7 +486,7 @@ int zmq::stream_engine_t::push_msg (msg_t *msg_)
|
|||||||
void zmq::stream_engine_t::error ()
|
void zmq::stream_engine_t::error ()
|
||||||
{
|
{
|
||||||
zmq_assert (session);
|
zmq_assert (session);
|
||||||
socket->event_disconnected (endpoint.c_str(), s);
|
socket->event_disconnected (endpoint, s);
|
||||||
session->detach ();
|
session->detach ();
|
||||||
unplug ();
|
unplug ();
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -132,7 +132,7 @@ namespace zmq
|
|||||||
options_t options;
|
options_t options;
|
||||||
|
|
||||||
// String representation of endpoint
|
// String representation of endpoint
|
||||||
std::string endpoint;
|
char *endpoint;
|
||||||
|
|
||||||
bool plugged;
|
bool plugged;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user