Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map-size restriction to avoid overflow and nullptr caused by user-misconfiguration #3242

Merged
merged 11 commits into from
Oct 14, 2022
12 changes: 12 additions & 0 deletions nav2_costmap_2d/src/costmap_2d_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,21 @@ Costmap2DROS::dynamicParametersCallback(std::vector<rclcpp::Parameter> parameter
if (name == "width") {
resize_map = true;
map_width_meters_ = parameter.as_int();
if (map_width_meters_ <= 0) {
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
RCLCPP_WARN(
get_logger(), "You've set width of map to be negative,"
" this isn't allowed, so the width will be set to be default value 5.");
map_width_meters_ = 5;
}
} else if (name == "height") {
resize_map = true;
map_height_meters_ = parameter.as_int();
if (map_height_meters_ <= 0) {
RCLCPP_WARN(
get_logger(), "You've set height of map to be negative,"
" this isn't allowed, so the height will be set to be default value 5.");
map_height_meters_ = 5;
}
}
} else if (type == ParameterType::PARAMETER_STRING) {
if (name == "footprint") {
Expand Down