Fix rcl_parse_yaml_file() error handling. (#776) (#786)

It should not fini its output argument, silently invalidating the given pointer.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
This commit is contained in:
Michel Hidalgo 2020-09-24 10:14:41 -03:00 committed by GitHub
parent c5e903a38a
commit a26c9cf575
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View file

@ -57,9 +57,11 @@ RCL_YAML_PARAM_PARSER_PUBLIC
void rcl_yaml_node_struct_fini( void rcl_yaml_node_struct_fini(
rcl_params_t * params_st); 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[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 /// \return true on success and false on failure
RCL_YAML_PARAM_PARSER_PUBLIC RCL_YAML_PARAM_PARSER_PUBLIC
bool rcl_parse_yaml_file( bool rcl_parse_yaml_file(

View file

@ -1801,12 +1801,7 @@ bool rcl_parse_yaml_file(
allocator.deallocate(ns_tracker.parameter_ns, allocator.state); allocator.deallocate(ns_tracker.parameter_ns, allocator.state);
} }
if (RCUTILS_RET_OK != ret) { return RCUTILS_RET_OK == ret;
rcl_yaml_node_struct_fini(params_st);
return false;
}
return true;
} }
/// ///