@@ -122,7 +122,10 @@ _filter_action_names(
122122 // Cleanup if there is an error
123123 if (RCL_RET_OK != ret ) {
124124 rcl_ret_t fini_ret = rcl_names_and_types_fini (action_names_and_types );
125- (void )fini_ret ; // Error already set
125+ if (RCL_RET_OK != fini_ret ) {
126+ RCUTILS_SAFE_FWRITE_TO_STDERR (
127+ "Freeing names and types failed while handling a previous error. Leaking memory!" );
128+ }
126129 }
127130
128131 return ret ;
@@ -154,6 +157,10 @@ rcl_action_get_client_names_and_types_by_node(
154157 rcl_ret_t nat_fini_ret = rcl_names_and_types_fini (& topic_names_and_types );
155158 if (RCL_RET_OK != nat_fini_ret ) {
156159 ret = rcl_names_and_types_fini (action_names_and_types );
160+ if (RCL_RET_OK != ret ) {
161+ RCUTILS_SAFE_FWRITE_TO_STDERR (
162+ "Freeing names and types failed while handling a previous error. Leaking memory!" );
163+ }
157164 return nat_fini_ret ;
158165 }
159166 return ret ;
@@ -185,6 +192,11 @@ rcl_action_get_server_names_and_types_by_node(
185192 rcl_ret_t nat_fini_ret = rcl_names_and_types_fini (& topic_names_and_types );
186193 if (RCL_RET_OK != nat_fini_ret ) {
187194 ret = rcl_names_and_types_fini (action_names_and_types );
195+ if (RCL_RET_OK != ret ) {
196+ RCUTILS_SAFE_FWRITE_TO_STDERR (
197+ "Freeing names and types failed while handling a previous error. Leaking memory!" );
198+ }
199+
188200 return nat_fini_ret ;
189201 }
190202 return ret ;
@@ -211,6 +223,10 @@ rcl_action_get_names_and_types(
211223 rcl_ret_t nat_fini_ret = rcl_names_and_types_fini (& topic_names_and_types );
212224 if (RCL_RET_OK != nat_fini_ret ) {
213225 ret = rcl_names_and_types_fini (action_names_and_types );
226+ if (RCL_RET_OK != ret ) {
227+ RCUTILS_SET_ERROR_MSG (
228+ "Freeing names and types failed while handling a previous error. Leaking memory!" );
229+ }
214230 return nat_fini_ret ;
215231 }
216232 return ret ;
0 commit comments