Skip to content

Commit

Permalink
Fix UB in SpiralIterator::operator++
Browse files Browse the repository at this point in the history
* Calling pop_back on an iterator past the end is UB

Signed-off-by: Ryan Friedman <[email protected]>
  • Loading branch information
Ryanf55 committed Nov 8, 2024
1 parent 38e57e2 commit 78b5ceb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions grid_map_core/src/iterators/SpiralIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const Eigen::Array2i & SpiralIterator::operator*() const

SpiralIterator & SpiralIterator::operator++()
{
if (isPastEnd()) {
return *this;
}
pointsRing_.pop_back();
if (pointsRing_.empty() && !isPastEnd()) {generateRing();}
return *this;
Expand Down

0 comments on commit 78b5ceb

Please sign in to comment.