Skip to content

Commit

Permalink
Only destroy security options when they were created
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
  • Loading branch information
ivanpauno committed Jan 31, 2020
1 parent 71cb800 commit 015f713
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ rcl_node_init(
rcl_ret_t ret;
rcl_ret_t fail_ret = RCL_RET_ERROR;
char * remapped_node_name = NULL;
rmw_security_options_t node_security_options =
rmw_get_zero_initialized_security_options();
rmw_security_options_t * node_security_options_ptr = NULL;

// Check options and allocator first, so allocator can be used for errors.
RCL_CHECK_ARGUMENT_FOR_NULL(options, RCL_RET_INVALID_ARGUMENT);
Expand Down Expand Up @@ -262,9 +265,6 @@ rcl_node_init(
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Using domain ID of '%zu'", domain_id);
node->impl->actual_domain_id = domain_id;

rmw_security_options_t node_security_options =
rmw_get_zero_initialized_security_options();
rmw_security_options_t * node_security_options_ptr = NULL;
if (rmw_use_node_name_in_security_directory_lookup()) {
node_security_options_ptr = &node_security_options;
ret = rcl_get_security_options_from_environment(
Expand Down Expand Up @@ -383,7 +383,9 @@ rcl_node_init(
if (NULL != remapped_node_name) {
allocator->deallocate(remapped_node_name, allocator->state);
}
rmw_security_options_fini(node_security_options_ptr, allocator);
if (node_security_options_ptr) {
rmw_security_options_fini(node_security_options_ptr, allocator);
}
return ret;
}

Expand Down

0 comments on commit 015f713

Please sign in to comment.