Skip to content

Commit 80dfb90

Browse files
MiguelCompanyjacobperron
authored andcommitted
Avoid memory leaks and undefined behavior in rmw_fastrtps_dynamic_cpp typesupport code (#429)
Signed-off-by: Miguel Company <[email protected]>
1 parent a798448 commit 80dfb90

File tree

2 files changed

+90
-296
lines changed

2 files changed

+90
-296
lines changed

rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct StringHelper<rosidl_typesupport_introspection_c__MessageMembers>
100100
return std::string(data.data);
101101
}
102102

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

123-
static void assign(eprosima::fastcdr::Cdr & deser, void * field, bool call_new)
123+
static void assign(eprosima::fastcdr::Cdr & deser, void * field)
124124
{
125125
std::string & str = *(std::string *)field;
126-
if (call_new) {
127-
new(&str) std::string;
128-
}
129126
deser >> str;
130127
}
131128
};
@@ -195,8 +192,7 @@ class TypeSupport : public BaseTypeSupport
195192
bool deserializeROSmessage(
196193
eprosima::fastcdr::Cdr & deser,
197194
const MembersType * members,
198-
void * ros_message,
199-
bool call_new) const;
195+
void * ros_message) const;
200196
};
201197

202198
} // namespace rmw_fastrtps_dynamic_cpp

0 commit comments

Comments
 (0)