Skip to content

Commit

Permalink
fix memory leak (#1994)
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
  • Loading branch information
Chen Lihui authored Aug 18, 2022
1 parent b953bdd commit 3d69031
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rclcpp/src/rclcpp/parameter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <vector>

#include "rcpputils/find_and_replace.hpp"
#include "rcpputils/scope_exit.hpp"
#include "rclcpp/parameter_map.hpp"

using rclcpp::exceptions::InvalidParametersException;
Expand Down Expand Up @@ -146,9 +147,11 @@ rclcpp::parameter_map_from_yaml_file(const std::string & yaml_filename)
{
rcutils_allocator_t allocator = rcutils_get_default_allocator();
rcl_params_t * rcl_parameters = rcl_yaml_node_struct_init(allocator);
RCPPUTILS_SCOPE_EXIT(rcl_yaml_node_struct_fini(rcl_parameters); );
const char * path = yaml_filename.c_str();
if (!rcl_parse_yaml_file(path, rcl_parameters)) {
rclcpp::exceptions::throw_from_rcl_error(RCL_RET_ERROR);
}

return rclcpp::parameter_map_from(rcl_parameters);
}

0 comments on commit 3d69031

Please sign in to comment.