From f341413248b2ddf236d742eecd37c52aef36fad3 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 26 May 2025 18:34:00 +0200 Subject: [PATCH] fix: Crash when opening diff view #2269 --- lib/libimhex/source/api/imhex_api.cpp | 3 +++ plugins/ui/include/ui/hex_editor.hpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 50b3a98de..6ecfcdb16 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -102,6 +102,9 @@ namespace hex { static PerProvider> s_hoveredRegion; void setHoveredRegion(const prv::Provider *provider, const Region ®ion) { + if (provider == nullptr) + return; + if (region == Region::Invalid()) s_hoveredRegion.get(provider).reset(); else diff --git a/plugins/ui/include/ui/hex_editor.hpp b/plugins/ui/include/ui/hex_editor.hpp index 0976abeed..e56546b3d 100644 --- a/plugins/ui/include/ui/hex_editor.hpp +++ b/plugins/ui/include/ui/hex_editor.hpp @@ -34,14 +34,14 @@ namespace hex::ui { } ImS64& get() { - if (m_synced) + if (m_synced || m_provider == nullptr) return m_syncedPosition; else return m_unsyncedPosition.get(m_provider); } [[nodiscard]] const ImS64& get() const { - if (m_synced) + if (m_synced || m_provider == nullptr) return m_syncedPosition; else return m_unsyncedPosition.get(m_provider);