Skip to content

Commit

Permalink
Avoid memory leaks and undefined behavior in rmw_fastrtps_dynamic_cpp…
Browse files Browse the repository at this point in the history
… typesupport code (#429)

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>
  • Loading branch information
MiguelCompany authored and nuclearsandwich committed May 18, 2021
1 parent 32a121a commit 07b9ed5
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct StringHelper<rosidl_typesupport_introspection_c__MessageMembers>
return std::string(data.data);
}

static void assign(eprosima::fastcdr::Cdr & deser, void * field, bool)
static void assign(eprosima::fastcdr::Cdr & deser, void * field)
{
std::string str;
deser >> str;
Expand All @@ -120,12 +120,9 @@ struct StringHelper<rosidl_typesupport_introspection_cpp::MessageMembers>
return *(static_cast<std::string *>(data));
}

static void assign(eprosima::fastcdr::Cdr & deser, void * field, bool call_new)
static void assign(eprosima::fastcdr::Cdr & deser, void * field)
{
std::string & str = *(std::string *)field;
if (call_new) {
new(&str) std::string;
}
deser >> str;
}
};
Expand Down Expand Up @@ -195,8 +192,7 @@ class TypeSupport : public BaseTypeSupport
bool deserializeROSmessage(
eprosima::fastcdr::Cdr & deser,
const MembersType * members,
void * ros_message,
bool call_new) const;
void * ros_message) const;
};

} // namespace rmw_fastrtps_dynamic_cpp
Expand Down
Loading

0 comments on commit 07b9ed5

Please sign in to comment.