Ver Fonte

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)
Pedro Rodrigues há 4 anos atrás
pai
commit
138d5121eb
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      scene/resources/texture.cpp

+ 1 - 1
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<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();