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

Fix memory leak on serialized message in test_publisher/subscription.cpp #801

Merged
merged 3 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions rcl/test/rcl/test_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ TEST_F(
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT(
{
test_msgs__msg__Strings__fini(&msg);
ASSERT_EQ(
RCUTILS_RET_OK,
rmw_serialized_message_fini(&serialized_msg)) << rcl_get_error_string().str;
Copy link
Collaborator

@iuhilnehc-ynos iuhilnehc-ynos Sep 15, 2020

Choose a reason for hiding this comment

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

Suggested change
ASSERT_EQ(
RCUTILS_RET_OK,
rmw_serialized_message_fini(&serialized_msg)) << rcl_get_error_string().str;
ASSERT_EQ(
RMW_RET_OK,
rmw_serialized_message_fini(&serialized_msg)) << rcl_get_error_string().str;

If we follow the interface description, maybe we need to update the return value, and also about the rmw_serialized_message_init in this test file.

https://github.com/ros2/rmw/blob/efe3f2bf932aabd70e875228e39b843103f2c4b3/rmw/include/rmw/serialized_message.h#L60-L72

});

ASSERT_TRUE(rosidl_runtime_c__String__assign(&msg.string_value, test_string));
Expand Down
8 changes: 8 additions & 0 deletions rcl/test/rcl/test_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@ TEST_F(CLASSNAME(TestSubscriptionFixture, RMW_IMPLEMENTATION), test_subscription
{
ret = rcl_subscription_fini(&subscription, this->node_ptr);
EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;

test_msgs__msg__Strings__fini(&msg);
ret = rmw_serialized_message_fini(&serialized_msg);
ASSERT_EQ(RCUTILS_RET_OK, ret) << rcl_get_error_string().str;
});
rcl_reset_error();

Expand All @@ -595,6 +599,10 @@ TEST_F(CLASSNAME(TestSubscriptionFixture, RMW_IMPLEMENTATION), test_subscription
ASSERT_EQ(RMW_RET_OK, ret);
ASSERT_EQ(
std::string(test_string), std::string(msg_rcv.string_value.data, msg_rcv.string_value.size));

test_msgs__msg__Strings__fini(&msg_rcv);
ret = rmw_serialized_message_fini(&serialized_msg_rcv);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
}
}

Expand Down