diff --git a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp index 53efedec4..8216f71f3 100644 --- a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp @@ -641,7 +641,13 @@ inline void deserialize_field( } deser >> *static_cast(field); } else if (member->array_size_ && !member->is_upper_bound_) { - deser.deserializeArray(static_cast(field), member->array_size_); + std::string * array = static_cast(field); + if (call_new) { + for (size_t i = 0; i < member->array_size_; ++i) { + new(&array[i]) std::string(); + } + } + deser.deserializeArray(array, member->array_size_); } else { auto & vector = *reinterpret_cast *>(field); if (call_new) { diff --git a/rmw_fastrtps_dynamic_cpp/src/rmw_serialize.cpp b/rmw_fastrtps_dynamic_cpp/src/rmw_serialize.cpp index 2fcd1831c..6af64af4f 100644 --- a/rmw_fastrtps_dynamic_cpp/src/rmw_serialize.cpp +++ b/rmw_fastrtps_dynamic_cpp/src/rmw_serialize.cpp @@ -48,7 +48,8 @@ rmw_serialize( } } - eprosima::fastcdr::FastBuffer buffer(reinterpret_cast(serialized_message->buffer), data_length); + eprosima::fastcdr::FastBuffer buffer(reinterpret_cast(serialized_message->buffer), + data_length); eprosima::fastcdr::Cdr ser( buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);