Merge pull request #49583 from timothyqiu/texture-crash

Fix crash when freeing GradientTexture and NoiseTexture
This commit is contained in:
Rémi Verschelde 2021-06-24 09:40:42 +02:00 committed by GitHub
commit f1bcc641dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -351,6 +351,9 @@ public:
for (size_t i = 0; i < max_alloc; i++) { for (size_t i = 0; i < max_alloc; i++) {
uint64_t validator = validator_chunks[i / elements_in_chunk][i % elements_in_chunk]; uint64_t validator = validator_chunks[i / elements_in_chunk][i % elements_in_chunk];
if (validator & 0x80000000) {
continue; //uninitialized
}
if (validator != 0xFFFFFFFF) { if (validator != 0xFFFFFFFF) {
chunks[i / elements_in_chunk][i % elements_in_chunk].~T(); chunks[i / elements_in_chunk][i % elements_in_chunk].~T();
} }

View File

@ -187,6 +187,7 @@ Ref<OpenSimplexNoise> NoiseTexture::get_noise() {
} }
void NoiseTexture::set_width(int p_width) { void NoiseTexture::set_width(int p_width) {
ERR_FAIL_COND(p_width <= 0);
if (p_width == size.x) { if (p_width == size.x) {
return; return;
} }
@ -195,6 +196,7 @@ void NoiseTexture::set_width(int p_width) {
} }
void NoiseTexture::set_height(int p_height) { void NoiseTexture::set_height(int p_height) {
ERR_FAIL_COND(p_height <= 0);
if (p_height == size.y) { if (p_height == size.y) {
return; return;
} }

View File

@ -1595,6 +1595,7 @@ void GradientTexture::_update() {
} }
void GradientTexture::set_width(int p_width) { void GradientTexture::set_width(int p_width) {
ERR_FAIL_COND(p_width <= 0);
width = p_width; width = p_width;
_queue_update(); _queue_update();
} }