From 138d5121ebfc475062f2544287c3227b8fd0e941 Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Wed, 3 Mar 2021 23:53:55 +0000 Subject: [PATCH] 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 46218d8c37cadee78f77e8bf0da13aebeff07ab1) --- scene/resources/texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 17e67c2a20..362ec78808 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -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 &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();