Skip to content

Commit

Permalink
Fix rcl_parse_yaml_file() error handling. (#776) (#786)
Browse files Browse the repository at this point in the history
It should not fini its output argument, silently invalidating the given pointer.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic authored Sep 24, 2020
1 parent c5e903a commit a26c9cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 4 additions & 2 deletions rcl_yaml_param_parser/include/rcl_yaml_param_parser/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ RCL_YAML_PARAM_PARSER_PUBLIC
void rcl_yaml_node_struct_fini(
rcl_params_t * params_st);

/// \brief Parse the YAML file, initialize and populate params_st
/// \brief Parse the YAML file and populate \p params_st
/// \pre Given \p params_st must be a valid parameter struct
/// as returned by `rcl_yaml_node_struct_init()`
/// \param[in] file_path is the path to the YAML file
/// \param[inout] params_st points to the populated parameter struct
/// \param[inout] params_st points to the struct to be populated
/// \return true on success and false on failure
RCL_YAML_PARAM_PARSER_PUBLIC
bool rcl_parse_yaml_file(
Expand Down
7 changes: 1 addition & 6 deletions rcl_yaml_param_parser/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1801,12 +1801,7 @@ bool rcl_parse_yaml_file(
allocator.deallocate(ns_tracker.parameter_ns, allocator.state);
}

if (RCUTILS_RET_OK != ret) {
rcl_yaml_node_struct_fini(params_st);
return false;
}

return true;
return RCUTILS_RET_OK == ret;
}

///
Expand Down

0 comments on commit a26c9cf

Please sign in to comment.