Skip to content

Commit

Permalink
Use correct functions to resize and get an item, avoiding memory leak…
Browse files Browse the repository at this point in the history
…s in typesupport code (ros2#228)

Signed-off-by: Chen.Lihui <lihui.chen@sony.com>
  • Loading branch information
Chen Lihui authored and eboasson committed May 17, 2021
1 parent 01454e6 commit 802058c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 224 deletions.
10 changes: 3 additions & 7 deletions rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct StringHelper<rosidl_typesupport_introspection_c__MessageMembers>
return std::string(data.data);
}

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

static void assign(cycdeser & deser, void * field, bool call_new)
static void assign(cycdeser & deser, void * field)
{
std::string & str = *(std::string *)field;
if (call_new) {
new(&str) std::string;
}
deser >> str;
}
};
Expand Down Expand Up @@ -131,8 +128,7 @@ class TypeSupport

private:
bool deserializeROSmessage(
cycdeser & deser, const MembersType * members, void * ros_message,
bool call_new);
cycdeser & deser, const MembersType * members, void * ros_message);
bool printROSmessage(
cycprint & deser, const MembersType * members);
};
Expand Down
Loading

0 comments on commit 802058c

Please sign in to comment.