Fix memory corruption when maximum number of parameters is exceeded (#456)
If the maximum number is exceeded fail with an informative error message. Fixes #419. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
parent
79b3ec1052
commit
ec8539b65c
3 changed files with 546 additions and 0 deletions
|
@ -225,6 +225,24 @@ TEST(test_file_parser, indented_ns) {
|
|||
allocator.deallocate(path, allocator.state);
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/ros2/rcl/issues/419
|
||||
TEST(test_file_parser, maximum_number_parameters) {
|
||||
rcutils_reset_error();
|
||||
EXPECT_TRUE(rcutils_get_cwd(cur_dir, 1024));
|
||||
rcutils_allocator_t allocator = rcutils_get_default_allocator();
|
||||
char * test_path = rcutils_join_path(cur_dir, "test", allocator);
|
||||
char * path = rcutils_join_path(test_path, "max_num_params.yaml", allocator);
|
||||
fprintf(stderr, "cur_path: %s\n", path);
|
||||
EXPECT_TRUE(rcutils_exists(path));
|
||||
rcl_params_t * params_hdl = rcl_yaml_node_struct_init(allocator);
|
||||
EXPECT_FALSE(NULL == params_hdl);
|
||||
bool res = rcl_parse_yaml_file(path, params_hdl);
|
||||
fprintf(stderr, "%s\n", rcutils_get_error_string().str);
|
||||
EXPECT_FALSE(res);
|
||||
allocator.deallocate(test_path, allocator.state);
|
||||
allocator.deallocate(path, allocator.state);
|
||||
}
|
||||
|
||||
int32_t main(int32_t argc, char ** argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue