From f45cc3fc732d2b5e88e3980394d959228db41fb8 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 31 Dec 2021 11:05:02 +0100 Subject: [PATCH] patterns: Potentially fix issues with nested pointers with custom base addresses Closes #367 --- plugins/libimhex/include/hex/pattern_language/ast_node.hpp | 4 ++-- .../libimhex/include/hex/pattern_language/pattern_data.hpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp index 3e1775a0d..e815ee39b 100644 --- a/plugins/libimhex/include/hex/pattern_language/ast_node.hpp +++ b/plugins/libimhex/include/hex/pattern_language/ast_node.hpp @@ -1138,6 +1138,8 @@ namespace hex::pl { auto pattern = new PatternDataPointer(offset, sizePattern->getSize(), evaluator); pattern->setVariableName(this->m_name); + applyVariableAttributes(evaluator, this, pattern); + offset = evaluator->dataOffset(); { @@ -1155,8 +1157,6 @@ namespace hex::pl { evaluator->dataOffset() = offset; - applyVariableAttributes(evaluator, this, pattern); - return { pattern }; } diff --git a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp index dddd02cb1..efb72976b 100644 --- a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp +++ b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp @@ -440,12 +440,14 @@ namespace hex::pl { } void rebase(u64 base) { - this->m_pointedAt->setOffset((this->m_pointedAt->getOffset() - this->m_pointerBase) + base); + if (this->m_pointedAt != nullptr) + this->m_pointedAt->setOffset((this->m_pointedAt->getOffset() - this->m_pointerBase) + base); + this->m_pointerBase = base; } private: - PatternData *m_pointedAt; + PatternData *m_pointedAt = nullptr; u64 m_pointerBase = 0; };