Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error sending more than 256 fragments <1.9.x> [7403] #973

Merged
merged 9 commits into from
Jan 24, 2020
16 changes: 14 additions & 2 deletions include/fastrtps/rtps/common/CDRMessage_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct RTPS_DllAPI CDRMessage_t{
length = 0;
buffer = (octet*) malloc(RTPSMESSAGE_DEFAULT_SIZE);
max_size = RTPSMESSAGE_DEFAULT_SIZE;
reserved_size = RTPSMESSAGE_DEFAULT_SIZE;

#if __BIG_ENDIAN__
msg_endian = BIGEND;
Expand Down Expand Up @@ -84,6 +85,7 @@ struct RTPS_DllAPI CDRMessage_t{
buffer = nullptr;

max_size = size;
reserved_size = size;

#if __BIG_ENDIAN__
msg_endian = BIGEND;
Expand All @@ -103,6 +105,7 @@ struct RTPS_DllAPI CDRMessage_t{
length = payload.length;
buffer = payload.data;
max_size = payload.max_size;
reserved_size = payload.max_size;
}

CDRMessage_t(const CDRMessage_t& message)
Expand All @@ -113,6 +116,7 @@ struct RTPS_DllAPI CDRMessage_t{
max_size = message.max_size;
msg_endian = message.msg_endian;

reserved_size = max_size;
if(max_size != 0)
{
buffer = (octet*)malloc(max_size);
Expand All @@ -132,6 +136,8 @@ struct RTPS_DllAPI CDRMessage_t{
message.length = 0;
max_size = message.max_size;
message.max_size = 0;
reserved_size = message.reserved_size;
message.reserved_size = 0;
msg_endian = message.msg_endian;
#if __BIG_ENDIAN__
message.msg_endian = BIGEND;
Expand All @@ -152,6 +158,8 @@ struct RTPS_DllAPI CDRMessage_t{
message.length = 0;
max_size = message.max_size;
message.max_size = 0;
reserved_size = message.reserved_size;
message.reserved_size = 0;
msg_endian = message.msg_endian;
#if __BIG_ENDIAN__
message.msg_endian = BIGEND;
Expand All @@ -168,7 +176,7 @@ struct RTPS_DllAPI CDRMessage_t{
uint32_t size)
{
assert(wraps == false);
if (size > max_size)
if (size > reserved_size)
{
octet* new_buffer = (octet*) realloc(buffer, size);
if (new_buffer == nullptr)
Expand All @@ -178,9 +186,11 @@ struct RTPS_DllAPI CDRMessage_t{
else
{
buffer = new_buffer;
max_size = size;
reserved_size = size;
}
}

max_size = size;
}

//!Pointer to the buffer where the data is stored.
Expand All @@ -189,6 +199,8 @@ struct RTPS_DllAPI CDRMessage_t{
uint32_t pos;
//!Max size of the message.
uint32_t max_size;
//!Max size of the message.
uint32_t reserved_size;
//!Current length of the message.
uint32_t length;
//!Endianness of the message.
Expand Down
Loading