From 775b3e8c52a5f597e08a34f98f20c8e38dc409c3 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 1 Mar 2022 20:17:03 +0100 Subject: [PATCH] patterns: Fixed crash when using control flow statements without value Fixes #460 --- .../ast/ast_node_control_flow_statement.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp b/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp index 1eb428fb1..ce7f400af 100644 --- a/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp @@ -34,12 +34,14 @@ namespace hex::pl { } FunctionResult execute(Evaluator *evaluator) const override { - auto returnValue = this->m_rvalue->evaluate(evaluator); - - auto literal = dynamic_cast(returnValue.get()); - evaluator->setCurrentControlFlowStatement(this->m_type); + if (this->m_rvalue == nullptr) + return std::nullopt; + + auto returnValue = this->m_rvalue->evaluate(evaluator); + auto literal = dynamic_cast(returnValue.get()); + if (literal == nullptr) return std::nullopt; else