From ab3a6fcd44df16b511070ad297e4b26838f520df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Wei=C3=9F?= Date: Tue, 21 Jul 2026 10:49:59 +0200 Subject: [PATCH] Fix segfault caused by calling nullptr->Write when the file could not be opened. --- Graphics/GraphicsTools/interface/RenderStateCache.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Graphics/GraphicsTools/interface/RenderStateCache.hpp b/Graphics/GraphicsTools/interface/RenderStateCache.hpp index 942715699b..403263d4f7 100644 --- a/Graphics/GraphicsTools/interface/RenderStateCache.hpp +++ b/Graphics/GraphicsTools/interface/RenderStateCache.hpp @@ -210,8 +210,10 @@ class RenderDeviceWithCache : public RenderDeviceX if (pCacheData) { FileWrapper CacheDataFile{FilePath, EFileAccessMode::Overwrite}; - if (CacheDataFile->Write(pCacheData->GetConstDataPtr(), pCacheData->GetSize())) + if (CacheDataFile && CacheDataFile->Write(pCacheData->GetConstDataPtr(), pCacheData->GetSize())) LOG_INFO_MESSAGE("Successfully saved state cache file ", FilePath, " (", FormatMemorySize(pCacheData->GetSize()), ")."); + else + LOG_ERROR_MESSAGE("Failed to save state cache file ", FilePath, " (", FormatMemorySize(pCacheData->GetSize()), ")."); } } else