diff --git a/rmw_fastrtps_cpp/src/rmw_node.cpp b/rmw_fastrtps_cpp/src/rmw_node.cpp index 3a39fc04d..a4915afa0 100644 --- a/rmw_fastrtps_cpp/src/rmw_node.cpp +++ b/rmw_fastrtps_cpp/src/rmw_node.cpp @@ -196,7 +196,8 @@ get_security_file_paths( std::string file_prefix("file://"); for (size_t i = 0; i < num_files; i++) { - char * file_path = rcutils_join_path(node_secure_root, file_names[i]); + rcutils_allocator_t allocator = rcutils_get_default_allocator(); + char * file_path = rcutils_join_path(node_secure_root, file_names[i], allocator); if (!file_path) { return false; @@ -205,11 +206,11 @@ get_security_file_paths( if (rcutils_is_readable(file_path)) { security_files_paths[i] = file_prefix + std::string(file_path); } else { - free(file_path); + allocator.deallocate(file_path, allocator.state); return false; } - free(file_path); + allocator.deallocate(file_path, allocator.state); } return true;