From 77ff98f76b3482dd3ad22cd4d691f3c1655ec131 Mon Sep 17 00:00:00 2001 From: y-okumura-isp Date: Mon, 3 Feb 2020 18:14:28 +0900 Subject: [PATCH 1/2] Fix memory leak in test_count_matched, fini subscription (#469) Signed-off-by: y-okumura-isp --- rcl/test/rcl/test_count_matched.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rcl/test/rcl/test_count_matched.cpp b/rcl/test/rcl/test_count_matched.cpp index 175f0cb14..86c801965 100644 --- a/rcl/test/rcl/test_count_matched.cpp +++ b/rcl/test/rcl/test_count_matched.cpp @@ -186,6 +186,14 @@ TEST_F(CLASSNAME(TestCountFixture, RMW_IMPLEMENTATION), test_count_matched_funct check_state(wait_set_ptr, nullptr, &sub, graph_guard_condition, -1, 0, 9); check_state(wait_set_ptr, nullptr, &sub2, graph_guard_condition, -1, 0, 9); + + ret = rcl_subscription_fini(&sub, this->node_ptr); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + rcl_reset_error(); + + ret = rcl_subscription_fini(&sub2, this->node_ptr); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + rcl_reset_error(); } TEST_F( @@ -241,6 +249,14 @@ TEST_F( check_state(wait_set_ptr, &pub, &sub, graph_guard_condition, 0, 0, 9); check_state(wait_set_ptr, &pub, &sub2, graph_guard_condition, 0, 0, 9); + ret = rcl_subscription_fini(&sub, this->node_ptr); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + rcl_reset_error(); + + ret = rcl_subscription_fini(&sub2, this->node_ptr); + EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + rcl_reset_error(); + ret = rcl_publisher_fini(&pub, this->node_ptr); EXPECT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; rcl_reset_error(); From b59df1f8023898e88e454f8f49331ac6f5838131 Mon Sep 17 00:00:00 2001 From: y-okumura-isp Date: Mon, 3 Feb 2020 18:36:53 +0900 Subject: [PATCH 2/2] Fix leak in test_count_matched, fini init_option (#469) Signed-off-by: y-okumura-isp --- rcl/test/rcl/test_count_matched.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rcl/test/rcl/test_count_matched.cpp b/rcl/test/rcl/test_count_matched.cpp index 86c801965..3b236d0eb 100644 --- a/rcl/test/rcl/test_count_matched.cpp +++ b/rcl/test/rcl/test_count_matched.cpp @@ -114,6 +114,8 @@ class CLASSNAME (TestCountFixture, RMW_IMPLEMENTATION) : public ::testing::Test *this->context_ptr = rcl_get_zero_initialized_context(); ret = rcl_init(0, nullptr, &init_options, this->context_ptr); ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; + ret = rcl_init_options_fini(&init_options); + ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; this->node_ptr = new rcl_node_t; *this->node_ptr = rcl_get_zero_initialized_node(); const char * name = "test_count_node";