From 4ad66365d04da70030a8b1679737817f0ab8e4c5 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 19 May 2023 20:01:42 +0200 Subject: [PATCH] fix: Crash when saving patches Fixes #1077 --- .../source/content/providers/file_provider.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index d01d2f248..f239fdd60 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -193,12 +193,16 @@ namespace hex::plugin::builtin { this->m_readable = true; this->m_writable = true; - wolv::io::File file(this->m_path, wolv::io::File::Mode::Read); + wolv::io::File file(this->m_path, wolv::io::File::Mode::Write); if (!file.isValid()) { this->m_writable = false; - this->m_readable = false; - this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, this->m_path.string(), ::strerror(errno))); - return false; + + file = wolv::io::File(this->m_path, wolv::io::File::Mode::Read); + if (!file.isValid()) { + this->m_readable = false; + this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, this->m_path.string(), ::strerror(errno))); + return false; + } } this->m_fileStats = file.getFileInfo();