mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-20 14:02:41 +02:00
Fixed wrong buffer end detection in v2_decoder.
zero-copy msg_t::init cannot be used when the message exceeds either the buffer end or the last received byte. To detect this, the buffer is now resized to the numnber of received bytes.
This commit is contained in:
@@ -43,7 +43,8 @@
|
||||
|
||||
zmq::shared_message_memory_allocator::shared_message_memory_allocator(size_t bufsize_):
|
||||
buf(NULL),
|
||||
bufsize( bufsize_ )
|
||||
bufsize( 0 ),
|
||||
maxsize( bufsize_ )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -71,6 +72,7 @@ unsigned char* zmq::shared_message_memory_allocator::allocate()
|
||||
new(buf) atomic_counter_t(1);
|
||||
}
|
||||
|
||||
bufsize = maxsize;
|
||||
return buf + sizeof( zmq::atomic_counter_t);
|
||||
}
|
||||
|
||||
@@ -78,12 +80,15 @@ void zmq::shared_message_memory_allocator::deallocate()
|
||||
{
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
bufsize = 0;
|
||||
}
|
||||
|
||||
unsigned char* zmq::shared_message_memory_allocator::release()
|
||||
{
|
||||
unsigned char* b = buf;
|
||||
buf = NULL;
|
||||
bufsize = 0;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user