From 4a5f1038e08700d74fce1f974abf444050921bbf Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 31 Dec 2023 14:58:20 +0100 Subject: [PATCH] fix: Crash when opening a file that cannot be mapped into memory --- lib/external/libwolv | 2 +- plugins/builtin/source/content/providers/file_provider.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/external/libwolv b/lib/external/libwolv index d25459dfa..b3665a698 160000 --- a/lib/external/libwolv +++ b/lib/external/libwolv @@ -1 +1 @@ -Subproject commit d25459dfa8e706af938427e979e454a8326c5984 +Subproject commit b3665a698d3484a992d820051d93286af750decf diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index b49816bc1..806c34df9 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -232,7 +232,11 @@ namespace hex::plugin::builtin { m_fileStats = file.getFileInfo(); m_file = std::move(file); - m_file.map(); + if (!m_file.map()) { + this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), ::strerror(errno))); + return false; + } + m_fileSize = m_file.getSize(); m_file.close();