fix: Crash when opening a file that cannot be mapped into memory

This commit is contained in:
WerWolv
2023-12-31 14:58:20 +01:00
parent 8cb833eca9
commit 4a5f1038e0
2 changed files with 6 additions and 2 deletions

View File

@@ -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();