Fix crash trying to destroy an ImageTexture object containing a null texture

The problem happened when `ImageTexture::create_from_image` was called
with an empty image. In this situation an RID was allocated despite the
texture being null. The destructor would then crash trying to acess this
null texture.

Fixes #46274

(cherry picked from commit 46218d8c37)
This commit is contained in:
Pedro Rodrigues 2021-03-03 23:53:55 +00:00 committed by Rémi Verschelde
parent b82d5688b9
commit 138d5121eb

View file

@ -196,7 +196,7 @@ void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uin
}
void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags) {
ERR_FAIL_COND(p_image.is_null());
ERR_FAIL_COND_MSG(p_image.is_null() || p_image->empty(), "Invalid image");
flags = p_flags;
w = p_image->get_width();
h = p_image->get_height();