Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct functions to resize and get an item, avoiding memory leaks in typesupport code #228

Merged
merged 6 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need to do the same in L101?

Copy link
Author

@iuhilnehc-ynos iuhilnehc-ynos Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to remove it. Sorry for my mistake.
I'll retest them(including rcl, rclcpp, system_tests) on my local environment.
If errors still exist, I'll investigate on them.

{
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