Skip to content

Commit

Permalink
fix leak in node.c
Browse files Browse the repository at this point in the history
  • Loading branch information
xabxx committed Apr 29, 2019
1 parent 64610d2 commit e05600a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,12 @@ rcl_node_init(
node_security_options.enforce_security = (0 == strcmp(ros_enforce_security, "Enforce")) ?
RMW_SECURITY_ENFORCEMENT_ENFORCE : RMW_SECURITY_ENFORCEMENT_PERMISSIVE;

char * node_secure_root = NULL;
if (!use_security) {
node_security_options.enforce_security = RMW_SECURITY_ENFORCEMENT_PERMISSIVE;
} else { // if use_security
// File discovery magic here
const char * node_secure_root = rcl_get_secure_root(name, local_namespace_, allocator);
node_secure_root = rcl_get_secure_root(name, local_namespace_, allocator);
if (node_secure_root) {
RCUTILS_LOG_INFO_NAMED(ROS_PACKAGE_NAME, "Found security directory: %s", node_secure_root);
node_security_options.security_root_path = node_secure_root;
Expand All @@ -320,6 +321,8 @@ rcl_node_init(
node->impl->rmw_node_handle = rmw_create_node(
&(node->context->impl->rmw_context),
name, local_namespace_, domain_id, &node_security_options);
// node_secure_root is only used for rmw_create_node
allocator->deallocate(node_secure_root, allocator->state);

RCL_CHECK_FOR_NULL_WITH_MSG(
node->impl->rmw_node_handle, rmw_get_error_string().str, goto fail);
Expand Down Expand Up @@ -408,6 +411,9 @@ rcl_node_init(
if (NULL != remapped_node_name) {
allocator->deallocate(remapped_node_name, allocator->state);
}
if (!node_secure_root) {
allocator->deallocate(node_secure_root, allocator->state);
}
return ret;
}

Expand Down

0 comments on commit e05600a

Please sign in to comment.