Skip to content

fix(behavior_path_planner): prevent segfault in updateBoundary with index validation #10848

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,14 @@
0 < front_offset ? start_poly.bound_seg_idx + 1 : start_poly.bound_seg_idx;
const size_t removed_end_idx = end_poly.bound_seg_idx;

if (removed_start_idx > removed_end_idx || removed_end_idx >= updated_bound.size()) {
auto clock{rclcpp::Clock{RCL_ROS_TIME}};
RCLCPP_ERROR_STREAM_THROTTLE(

Check warning on line 624 in planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/drivable_area_expansion/static_drivable_area.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/drivable_area_expansion/static_drivable_area.cpp#L624

Added line #L624 was not covered by tests
rclcpp::get_logger("behavior_path_planner").get_child("utils"), clock, 1000,
"Invalid index for erase in updateBoundary. Skipping.");
continue;
}

Check warning on line 628 in planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/drivable_area_expansion/static_drivable_area.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/drivable_area_expansion/static_drivable_area.cpp#L628

Added line #L628 was not covered by tests

updated_bound.erase(
updated_bound.begin() + removed_start_idx, updated_bound.begin() + removed_end_idx + 1);

Expand Down
Loading