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
24 changes: 20 additions & 4 deletions nav2_costmap_2d/src/costmap_2d_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,27 @@ Costmap2DROS::dynamicParametersCallback(std::vector<rclcpp::Parameter> parameter
}
} else if (type == ParameterType::PARAMETER_INTEGER) {
if (name == "width") {
resize_map = true;
map_width_meters_ = parameter.as_int();
if (parameter.as_int() > 0) {
resize_map = true;
map_width_meters_ = parameter.as_int();
} else {
RCLCPP_ERROR(
get_logger(), "You try to set width of map to be negative or zero,"
" this isn't allowed, please give a positive value.");
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
result.successful = false;
return result;
}
} else if (name == "height") {
resize_map = true;
map_height_meters_ = parameter.as_int();
if (parameter.as_int() > 0) {
resize_map = true;
map_height_meters_ = parameter.as_int();
} else {
RCLCPP_ERROR(
get_logger(), "You try to set height of map to be negative or zero,"
" this isn't allowed, please give a positive value.");
result.successful = false;
return result;
}
}
} else if (type == ParameterType::PARAMETER_STRING) {
if (name == "footprint") {
Expand Down