Skip to content

Commit

Permalink
fix(behavior_velocity_crosswalk): fix segfo at crosswalk is empty case (
Browse files Browse the repository at this point in the history
#1287)

Note : range check for size_t (0 -1) is going to generate inf
Signed-off-by: tanaka3 <ttatcoder@outlook.jp>
  • Loading branch information
taikitanaka3 authored Jul 8, 2022
1 parent 6669059 commit ae1dcef
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,16 +731,18 @@ void CrosswalkModule::clampAttentionRangeByNeighborCrosswalks(
boost::optional<lanelet::ConstLanelet> prev_crosswalk{boost::none};
boost::optional<lanelet::ConstLanelet> next_crosswalk{boost::none};

for (size_t i = 0; i < crosswalks.size() - 1; ++i) {
const auto ll_front = crosswalks.at(i);
const auto ll_back = crosswalks.at(i + 1);
if (!crosswalks.empty()) {
for (size_t i = 0; i < crosswalks.size() - 1; ++i) {
const auto ll_front = crosswalks.at(i);
const auto ll_back = crosswalks.at(i + 1);

if (ll_front.id() == module_id_ && ll_back.id() != module_id_) {
next_crosswalk = ll_back;
}
if (ll_front.id() == module_id_ && ll_back.id() != module_id_) {
next_crosswalk = ll_back;
}

if (ll_front.id() != module_id_ && ll_back.id() == module_id_) {
prev_crosswalk = ll_front;
if (ll_front.id() != module_id_ && ll_back.id() == module_id_) {
prev_crosswalk = ll_front;
}
}
}

Expand Down

0 comments on commit ae1dcef

Please sign in to comment.