From 788582d5cbc6b5360110b294cefd2acde8279e68 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 1 May 2018 09:03:20 -0500 Subject: [PATCH] Fix deserialization segfault in bionic. --- .../include/rmw_fastrtps_cpp/TypeSupport_impl.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport_impl.hpp b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport_impl.hpp index 1d263638d..a4d5ac1a7 100644 --- a/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport_impl.hpp +++ b/rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/TypeSupport_impl.hpp @@ -573,6 +573,12 @@ bool TypeSupport::deserializeROSmessage( deserialize_field(member, field, deser, call_new); break; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_STRING: + // Because std::string is a complex datatype, we need to make sure that + // the memory is initialized to something reasonable before eventually + // passing it as a reference to Fast-CDR. + if(!member->is_array_) { + new (field) std::string(); + } deserialize_field(member, field, deser, call_new); break; case ::rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE: