mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Shell: Move the heredocs vector to a local value before processing it
Otherwise we would end up trying to parse the same heredoc entry, if it contained a sequence terminated by a newline. e.g. `<<-x\n$({` would attempt to read a heredoc entry after `x`, and then after `{` while inside the first heredoc entry. To make this work, we can simply empty the instance vector and keep the state on the stack. Issue found through oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33852
This commit is contained in:
parent
323a408d8c
commit
70728b49e2
Notes:
sideshowbarker
2024-07-18 18:49:13 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/70728b49e26 Pull-request: https://github.com/SerenityOS/serenity/pull/6773 Reviewed-by: https://github.com/awesomekling
1 changed files with 3 additions and 3 deletions
|
@ -1982,8 +1982,10 @@ RefPtr<AST::Node> Parser::parse_heredoc_initiation_record()
|
|||
|
||||
bool Parser::parse_heredoc_entries()
|
||||
{
|
||||
auto heredocs = move(m_heredoc_initiations);
|
||||
m_heredoc_initiations.clear();
|
||||
// Try to parse heredoc entries, as reverse recorded in the initiation records
|
||||
for (auto& record : m_heredoc_initiations) {
|
||||
for (auto& record : heredocs) {
|
||||
auto rule_start = push_start();
|
||||
if (m_rule_start_offsets.size() > max_allowed_nested_rule_depth) {
|
||||
record.node->set_is_syntax_error(*create<AST::SyntaxError>(String::formatted("Expression nested too deep (max allowed is {})", max_allowed_nested_rule_depth)));
|
||||
|
@ -2070,8 +2072,6 @@ bool Parser::parse_heredoc_entries()
|
|||
record.node->set_contents(create<AST::DoubleQuotedString>(move(expr)));
|
||||
}
|
||||
}
|
||||
|
||||
m_heredoc_initiations.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue