Skip to content

Commit d55b2ee

Browse files
Fix UB in SpiralIterator::operator++ (#481) (#487)
* 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]>
1 parent 747ddaa commit d55b2ee

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

grid_map_core/src/iterators/SpiralIterator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ const Eigen::Array2i & SpiralIterator::operator*() const
6666

6767
SpiralIterator & SpiralIterator::operator++()
6868
{
69+
if (isPastEnd()) {
70+
return *this;
71+
}
6972
pointsRing_.pop_back();
7073
if (pointsRing_.empty() && !isPastEnd()) {generateRing();}
7174
return *this;

0 commit comments

Comments
 (0)