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 overflow check in when generating NoiseTexture3D #88823

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

jsjtxietian
Copy link
Contributor

@jsjtxietian jsjtxietian commented Feb 25, 2024

Fixes #88800

The origin problem is that the MRP's NoiseTexture3D's width is 4096, height is 4096 and depth is 4096. And In Noise::_get_image it will call values.resize(p_width * p_height * p_depth), the values vector's capacity is uint32_t which can not handle 4096^3 and overflows, thus the resize failed, or more preciously speaking, it overflowed to 0, and the later vector indexing caused this crash.

My solution here, technically speaking is not overflow check but more like an sanity check that should be placed somewhere in NoiseTexture3D. Feel free to correct me.

Also the NoiseTexture2D may need the same check too, although it's less likely to have the same problem as NoiseTexture3D.

@emre0altan
Copy link
Contributor

emre0altan commented Feb 25, 2024

Limits it to the same memory allocation that maximum 2d texture has, looks good 👍

@akien-mga akien-mga changed the title Do overflow check in when gererating NoiseTexture3D Do overflow check in when generating NoiseTexture3D Feb 26, 2024
modules/noise/noise_texture_3d.cpp Outdated Show resolved Hide resolved
@akien-mga akien-mga merged commit bbe263d into godotengine:master Feb 27, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@jsjtxietian jsjtxietian deleted the limit-NoiseTexture3D branch February 27, 2024 09:50
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.

Altering the size of a NoiseTexture3D crashes the editor on startup
6 participants