Skip to content

Commit

Permalink
fix(behavior_path_planner): fix invalid access in avoidance module (#…
Browse files Browse the repository at this point in the history
…4081)

Signed-off-by: tomoya.kimura <tomoya.kimura@tier4.jp>
  • Loading branch information
tkimura4 authored Jun 26, 2023
1 parent ec6387a commit 52099a5
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3045,7 +3045,7 @@ TurnSignalInfo AvoidanceModule::calcTurnSignalInfo(const ShiftedPath & path) con
}

// compute blinker start idx and end idx
const size_t blinker_start_idx = [&]() {
size_t blinker_start_idx = [&]() {
for (size_t idx = start_idx; idx <= end_idx; ++idx) {
const double current_shift_length = path.shift_length.at(idx);
if (current_shift_length > 0.1) {
Expand All @@ -3054,7 +3054,13 @@ TurnSignalInfo AvoidanceModule::calcTurnSignalInfo(const ShiftedPath & path) con
}
return start_idx;
}();
const size_t blinker_end_idx = end_idx;
size_t blinker_end_idx = end_idx;

// prevent invalid access for out-of-range
blinker_start_idx =
std::min(std::max(std::size_t(0), blinker_start_idx), path.path.points.size() - 1);
blinker_end_idx =
std::min(std::max(blinker_start_idx, blinker_end_idx), path.path.points.size() - 1);

const auto blinker_start_pose = path.path.points.at(blinker_start_idx).point.pose;
const auto blinker_end_pose = path.path.points.at(blinker_end_idx).point.pose;
Expand Down

0 comments on commit 52099a5

Please sign in to comment.