From fdfa5c0bc72ca84ead96bed430acec988e47c49a Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 19 May 2021 21:08:23 +0430 Subject: [PATCH] Shell: Avoid moving AK::Function instances while inside them --- Userland/Shell/Parser.cpp | 4 ++-- Userland/Shell/Parser.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Shell/Parser.cpp b/Userland/Shell/Parser.cpp index a473cf73498..a7df601c90e 100644 --- a/Userland/Shell/Parser.cpp +++ b/Userland/Shell/Parser.cpp @@ -2037,7 +2037,7 @@ bool Parser::parse_heredoc_entries() // until we find a line that contains the key auto end_condition = move(m_end_condition); found_key = false; - set_end_condition([this, end = record.end, &found_key] { + set_end_condition(make>([this, end = record.end, &found_key] { if (found_key) return true; auto offset = current_position(); @@ -2060,7 +2060,7 @@ bool Parser::parse_heredoc_entries() } restore_to(offset.offset, offset.line); return false; - }); + })); auto expr = parse_doublequoted_string_inner(); set_end_condition(move(end_condition)); diff --git a/Userland/Shell/Parser.h b/Userland/Shell/Parser.h index ab6acd8cd75..de230c5f2c6 100644 --- a/Userland/Shell/Parser.h +++ b/Userland/Shell/Parser.h @@ -94,10 +94,10 @@ private: template NonnullRefPtr create(Args... args); - void set_end_condition(Function condition) { m_end_condition = move(condition); } + void set_end_condition(OwnPtr> condition) { m_end_condition = move(condition); } bool at_end() const { - if (m_end_condition && m_end_condition()) + if (m_end_condition && (*m_end_condition)()) return true; return m_input.length() <= m_offset; } @@ -159,7 +159,7 @@ private: Vector m_rule_start_offsets; Vector m_rule_start_lines; - Function m_end_condition; + OwnPtr> m_end_condition; Vector m_heredoc_initiations; Vector m_extra_chars_not_allowed_in_barewords; bool m_is_in_brace_expansion_spec { false };