Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not iterate over the map when size is 0 #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Smiffe
Copy link

@Smiffe Smiffe commented Jul 12, 2022

Hey,

I have noticed small bug within GridMapIterator. There are two situations in which GridMap object is empty (size is 0,0):

When using GridMapIterator as shown in README.md and demos https://github.com/ANYbotics/grid_map/blob/master/grid_map_demos/src/IteratorsDemo.cpp#L58, first iteration is always valid as isPastEnd_ variable is false regardless of the GridMap's size https://github.com/ANYbotics/grid_map/blob/master/grid_map_core/src/iterators/GridMapIterator.cpp#L20. Accessing empty GridMap leads to exception which crashes whole application as currently it's not catched or even documented.

I have added validation in GridMapIterator constructor which ensures GridMap is accessible. I have also added simple test to check if isPastEnd_ variable initializes with true value when passed GridMap is empty.

@maximilianwulf
Copy link
Collaborator

Thank you, will import it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants