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

Fix potential crashes with TileMap navmesh baking #83891

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

smix8
Copy link
Contributor

@smix8 smix8 commented Oct 24, 2023

Fixes potential crashes with TileMap navmesh baking.

I discovered this because a user send me a project that crashed on a large TileMap when baking a navigation mesh from it.

Turned out it was not the size in quantity of the cells that was crashing it. The parsing crashed due to calling size() with empty TileData which resulted in the TileSet index macro causing a CowData nullptr crash when calling navigation.size().

error

The reason the loop was even running was because the used cells count was not updated after TileMap.clear(). The TileMap reporting the wrong used cell count after clear() is fixed with #83890.

So this pr now guards the parsing process against empty TileData or empty / zero-sized outline arrays.
Also improves performance slightly for complex polygons by switching to ptr() / ptrw().

Fixes potential crashes with TileMap navmesh baking.
Copy link
Member

@groud groud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akien-mga akien-mga merged commit ea8b773 into godotengine:master Oct 25, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@smix8 smix8 deleted the tilemap_bake_crashes branch October 25, 2023 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants