From 17a2be41dab5e46a8ce0b87ac64137945824bbac Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 19 Mar 2022 00:24:41 +0100 Subject: [PATCH] patterns: Fixed crash when applying certain attributes to types --- .../hex/pattern_language/ast/ast_node_type_decl.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/include/hex/pattern_language/ast/ast_node_type_decl.hpp b/lib/libimhex/include/hex/pattern_language/ast/ast_node_type_decl.hpp index 7661e6563..656460601 100644 --- a/lib/libimhex/include/hex/pattern_language/ast/ast_node_type_decl.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast/ast_node_type_decl.hpp @@ -13,7 +13,7 @@ namespace hex::pl { ASTNodeTypeDecl(const ASTNodeTypeDecl &other) : ASTNode(other), Attributable(other) { this->m_name = other.m_name; - this->m_type = other.m_type->clone(); + this->m_type = other.m_type; this->m_endian = other.m_endian; } @@ -31,8 +31,11 @@ namespace hex::pl { if (auto attributable = dynamic_cast(type.get())) { for (auto &attribute : this->getAttributes()) { - if (auto node = dynamic_cast(attribute.get())) + auto copy = attribute->clone(); + if (auto node = dynamic_cast(copy.get())) { attributable->addAttribute(std::unique_ptr(node)); + (void)copy.release(); + } } }