From 68f93c5e3d031305e8fbab77997d3f6a8c91cde4 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 5 Dec 2020 22:30:09 +0100 Subject: [PATCH] Fixed possible crash when loading files, relax pattern detection requirements This fixes #20 --- source/views/view_pattern.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/views/view_pattern.cpp b/source/views/view_pattern.cpp index 1f95fb5ac..09ea7dcef 100644 --- a/source/views/view_pattern.cpp +++ b/source/views/view_pattern.cpp @@ -95,7 +95,7 @@ namespace hex { }); View::subscribeEvent(Events::FileLoaded, [this](const void* userData) { - if (!this->m_textEditor.GetText().empty()) + if (this->m_textEditor.GetText().find_first_not_of(" \f\n\r\t\v") != std::string::npos) return; lang::Preprocessor preprocessor; @@ -107,6 +107,9 @@ namespace hex { magicFiles += entry.path().string() + MAGIC_PATH_SEPARATOR; } + if (error) + return; + std::vector buffer(std::min(this->m_dataProvider->getSize(), size_t(0xFFFF)), 0x00); this->m_dataProvider->read(0, buffer.data(), buffer.size()); @@ -151,7 +154,7 @@ namespace hex { if (foundCorrectType) { this->m_possiblePatternFile = entry.path(); - ImGui::OpenPopup("Accept Pattern"); + View::doLater([] { ImGui::OpenPopup("Accept Pattern"); }); ImGui::SetNextWindowSize(ImVec2(200, 100)); break; }