Skip to content

Commit

Permalink
Correctly recalculate serialized size on bounded sequences. (#540)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany authored Aug 4, 2021
1 parent 649b1c0 commit 3ec96a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions rmw_fastrtps_cpp/src/type_support_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members)
max_size_bound_ = 0 != (bounds_info & ROSIDL_TYPESUPPORT_FASTRTPS_BOUNDED_TYPE);
is_plain_ = bounds_info == ROSIDL_TYPESUPPORT_FASTRTPS_PLAIN_TYPE;
#else
max_size_bound_ = true;
auto data_size = static_cast<uint32_t>(members->max_serialized_size(max_size_bound_));
is_plain_ = true;
auto data_size = static_cast<uint32_t>(members->max_serialized_size(is_plain_));
max_size_bound_ = is_plain_;
#endif

// A fully bound message of size 0 is an empty message
if (max_size_bound_ && (data_size == 0) ) {
// A plain message of size 0 is an empty message
if (is_plain_ && (data_size == 0) ) {
has_data_ = false;
++data_size; // Dummy byte
} else {
Expand All @@ -60,7 +61,7 @@ void TypeSupport::set_members(const message_type_support_callbacks_t * members)

size_t TypeSupport::getEstimatedSerializedSize(const void * ros_message, const void * impl) const
{
if (max_size_bound_) {
if (is_plain_) {
return m_typeSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ template<typename MembersType>
size_t TypeSupport<MembersType>::getEstimatedSerializedSize(
const void * ros_message, const void * impl) const
{
if (max_size_bound_) {
if (is_plain_) {
return m_typeSize;
}

Expand Down

0 comments on commit 3ec96a9

Please sign in to comment.