From 64e26770b93e782acf930c805c8cfc624636d7e0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 23 Dec 2024 17:33:51 +0200 Subject: [PATCH] Check if Collection::open_raw succeeded --- source/core/texturecube.cpp | 2 ++ source/materials/splatmaterial.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index e9a6f4ed..c46e5232 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -157,6 +157,8 @@ void TextureCube::Loader::external_image(TextureCubeFace face, const string &fn) { Graphics::Image img; unique_ptr io = get_collection().open_raw(fn); + if(!io) + throw IO::file_not_found(fn); img.load_io(*io); obj.image(face, img); diff --git a/source/materials/splatmaterial.cpp b/source/materials/splatmaterial.cpp index 9e5e665c..13e54a9a 100644 --- a/source/materials/splatmaterial.cpp +++ b/source/materials/splatmaterial.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "pbrmaterial.h" #include "resources.h" @@ -116,6 +117,9 @@ void SplatMaterial::upload_sub_map(DataFile::Collection &coll, unsigned index, S ++sub.layer; unique_ptr io = coll.open_raw(sub.source_fn); + if(!io) + throw IO::file_not_found(sub.source_fn); + char magic[4] = { }; io->read(magic, 4); io->seek(0, IO::S_BEG); -- 2.45.2