mirror of
https://github.com/zeromq/libzmq.git
synced 2025-02-07 14:30:15 +01:00
Fix request-handling memory leak
This commit is contained in:
parent
2c89c069a9
commit
367cedb7c6
22
src/req.cpp
22
src/req.cpp
@ -36,14 +36,6 @@
|
|||||||
#include "random.hpp"
|
#include "random.hpp"
|
||||||
#include "likely.hpp"
|
#include "likely.hpp"
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
static void free_id (void *data_, void *hint_)
|
|
||||||
{
|
|
||||||
LIBZMQ_UNUSED (hint_);
|
|
||||||
free (data_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
zmq::req_t::req_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
|
zmq::req_t::req_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
|
||||||
dealer_t (parent_, tid_, sid_),
|
dealer_t (parent_, tid_, sid_),
|
||||||
_receiving_reply (false),
|
_receiving_reply (false),
|
||||||
@ -81,22 +73,16 @@ int zmq::req_t::xsend (msg_t *msg_)
|
|||||||
if (_request_id_frames_enabled) {
|
if (_request_id_frames_enabled) {
|
||||||
_request_id++;
|
_request_id++;
|
||||||
|
|
||||||
// Copy request id before sending (see issue #1695 for details).
|
|
||||||
uint32_t *request_id_copy =
|
|
||||||
static_cast<uint32_t *> (malloc (sizeof (uint32_t)));
|
|
||||||
zmq_assert (request_id_copy);
|
|
||||||
|
|
||||||
*request_id_copy = _request_id;
|
|
||||||
|
|
||||||
msg_t id;
|
msg_t id;
|
||||||
int rc =
|
int rc = id.init_size (sizeof (uint32_t));
|
||||||
id.init_data (request_id_copy, sizeof (uint32_t), free_id, NULL);
|
memcpy (id.data (), &_request_id, sizeof (uint32_t));
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
id.set_flags (msg_t::more);
|
id.set_flags (msg_t::more);
|
||||||
|
|
||||||
rc = dealer_t::sendpipe (&id, &_reply_pipe);
|
rc = dealer_t::sendpipe (&id, &_reply_pipe);
|
||||||
if (rc != 0)
|
if (rc != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_t bottom;
|
msg_t bottom;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user