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) {