Skip to content

Commit 6701ff6

Browse files
Ryanf55mergify[bot]
authored andcommitted
Fix UB in SpiralIterator::operator++ (#481)
* Calling pop_back on an iterator past the end is UB Signed-off-by: Ryan Friedman <[email protected]> (cherry picked from commit 74dbbc8)
1 parent 747ddaa commit 6701ff6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

grid_map_core/src/iterators/SpiralIterator.cpp

+3
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)