Skip to content

Commit

Permalink
Fix UB in SpiralIterator::operator++ (#481) (#489)
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]>
(cherry picked from commit 74dbbc8)

Co-authored-by: Ryan <[email protected]>
  • Loading branch information
mergify[bot] and Ryanf55 authored Nov 28, 2024
1 parent 69c100f commit 855a4ac
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 855a4ac

Please sign in to comment.