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:
Jens Auer
2015-06-10 22:09:55 +02:00
parent b3f2acf7d6
commit dfe1908008
6 changed files with 29 additions and 2 deletions

View File

@@ -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;
}