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 leak in node.c #424

Merged
merged 2 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 1 deletion rcl/include/rcl/security_directory.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ extern "C"
* \param[in] node_namespace validated, absolute namespace (starting with "/")
* \param[in] allocator the allocator to use for allocation
* \returns machine specific (absolute) node secure root path or NULL on failure
xabxx marked this conversation as resolved.
Show resolved Hide resolved
* returned pointer must be deallocated by the caller of this function
*/
RCL_PUBLIC
const char * rcl_get_secure_root(
char * rcl_get_secure_root(
const char * node_name,
const char * node_namespace,
const rcl_allocator_t * allocator
Expand Down
4 changes: 3 additions & 1 deletion rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ rcl_node_init(
rcl_ret_t ret;
rcl_ret_t fail_ret = RCL_RET_ERROR;
char * remapped_node_name = NULL;
char * node_secure_root = 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 @@ -306,7 +307,7 @@ rcl_node_init(
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 Down Expand Up @@ -408,6 +409,7 @@ rcl_node_init(
if (NULL != remapped_node_name) {
allocator->deallocate(remapped_node_name, allocator->state);
}
allocator->deallocate(node_secure_root, allocator->state);
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion rcl/src/rcl/security_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ char * prefix_match_lookup(
return node_secure_root;
}

const char * rcl_get_secure_root(
char * rcl_get_secure_root(
const char * node_name,
const char * node_namespace,
const rcl_allocator_t * allocator)
Expand Down