Do overflow check in when generating NoiseTexture3D #88823
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 callvalues.resize(p_width * p_height * p_depth)
, the values vector's capacity is uint32_t which can not handle 4096^3 and overflows, thus theresize
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 asNoiseTexture3D
.