Merge pull request #14186 from JoshuaVandaele/dit-crash-fix

DITConfiguration: Prevent a crash if images fail to load
This commit is contained in:
JosJuice 2025-12-01 20:00:19 +01:00 committed by GitHub
commit efa8439b79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -150,7 +150,15 @@ void Configuration::GenerateTexture(const Common::IniFile& file,
}
else
{
const auto host_key_image = LoadImage(m_base_path + input_image_iter->second);
const std::string full_image_path = m_base_path + input_image_iter->second;
const auto host_key_image = LoadImage(full_image_path);
if (!host_key_image)
{
ERROR_LOG_FMT(VIDEO,
"Failed to load image '{}' needed for dynamic input texture generation",
full_image_path);
continue;
}
for (const auto& rect : rects)
{

View File

@ -45,9 +45,12 @@ void CopyImageRegion(const ImagePixelData& src, ImagePixelData& dst, const Rect&
std::optional<ImagePixelData> LoadImage(const std::string& path)
{
File::IOFile file;
file.Open(path, "rb");
if (!file.Open(path, "rb"))
return std::nullopt;
Common::UniqueBuffer<u8> buffer(file.GetSize());
file.ReadBytes(buffer.data(), file.GetSize());
if (!file.ReadBytes(buffer.data(), file.GetSize()))
return std::nullopt;
ImagePixelData image;
Common::UniqueBuffer<u8> data;