Skip to content

Commit 44bdadb

Browse files
committed
DDS: Prevent crashing when unable to load image
1 parent 09fcbb8 commit 44bdadb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

modules/dds/texture_loader_dds.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,15 @@ static Vector<Ref<Image>> _dds_load_images(Ref<FileAccess> p_f, DDSFormat p_dds_
392392

393393
for (uint32_t i = 0; i < p_layer_count; i++) {
394394
images.write[i] = _dds_load_layer(p_f, p_dds_format, p_width, p_height, p_mipmaps, p_pitch, p_flags, src_data);
395+
ERR_FAIL_COND_V(images.write[i].is_null(), Vector<Ref<Image>>());
395396
}
396397

397398
return images;
398399
}
399400

400401
static Ref<Resource> _dds_create_texture(const Vector<Ref<Image>> &p_images, uint32_t p_dds_type, uint32_t p_width, uint32_t p_height, uint32_t p_layer_count, uint32_t p_mipmaps, Error *r_error) {
402+
ERR_FAIL_COND_V(p_images.is_empty(), Ref<Resource>());
403+
401404
if ((p_dds_type & DDST_TYPE_MASK) == DDST_2D) {
402405
if (p_dds_type & DDST_ARRAY) {
403406
Ref<Texture2DArray> texture;

0 commit comments

Comments
 (0)