diff options
author | Pedro Rodrigues <pedro@onimail.net> | 2021-03-03 23:53:55 +0000 |
---|---|---|
committer | Pedro Rodrigues <pedro@onimail.net> | 2021-03-03 23:54:27 +0000 |
commit | 46218d8c37cadee78f77e8bf0da13aebeff07ab1 (patch) | |
tree | 4675de11c5a39ea3b4b34a5bfb183d8b92e24a17 | |
parent | 44e73473c6af24bc83ed2ec40a1c0162624dd8fc (diff) |
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
-rw-r--r-- | scene/resources/texture.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 8cccf81659..d2bb1338d8 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -151,7 +151,7 @@ void ImageTexture::_reload_hook(const RID &p_hook) { } void ImageTexture::create_from_image(const Ref<Image> &p_image) { - ERR_FAIL_COND_MSG(p_image.is_null(), "Invalid image"); + ERR_FAIL_COND_MSG(p_image.is_null() || p_image->is_empty(), "Invalid image"); w = p_image->get_width(); h = p_image->get_height(); format = p_image->get_format(); |