From 5a6dc310c002a2d9d75cf7de6bc1a984339ef533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Fri, 28 Nov 2025 18:13:46 +0100 Subject: DITConfiguration: Prevent a crash if images fail to load Recently came across a strange issue where Dolphin would hard crash in most games with this error: ```sh /usr/include/c++/15.2.1/optional:1165: constexpr const _Tp* std::optional<_Tp>::operator->() const [with _Tp = InputCommon::ImagePixelData]: Assertion 'this->_M_is_engaged()' failed. ``` The culprit turned out to be accessing `host_key_image` which is an `std::optional` thay may return `std::nullopt`. I'm not sure why this issue started occuring for me since I've had no issue with my Dynamic Input Textures in the past? But this fixes a crash if the image fails to load. --- Source/Core/InputCommon/ImageOperations.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Source/Core/InputCommon/ImageOperations.cpp') diff --git a/Source/Core/InputCommon/ImageOperations.cpp b/Source/Core/InputCommon/ImageOperations.cpp index 907cb52b8d..8fa844fec1 100644 --- a/Source/Core/InputCommon/ImageOperations.cpp +++ b/Source/Core/InputCommon/ImageOperations.cpp @@ -45,9 +45,12 @@ void CopyImageRegion(const ImagePixelData& src, ImagePixelData& dst, const Rect& std::optional LoadImage(const std::string& path) { File::IOFile file; - file.Open(path, "rb"); + if (!file.Open(path, "rb")) + return std::nullopt; + Common::UniqueBuffer buffer(file.GetSize()); - file.ReadBytes(buffer.data(), file.GetSize()); + if (!file.ReadBytes(buffer.data(), file.GetSize())) + return std::nullopt; ImagePixelData image; Common::UniqueBuffer data; -- cgit v1.2.3