mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-24 13:35:12 +00:00
Shell: Fix use-after-move in alias resolution
This unbreaks aliases!
This commit is contained in:
parent
fa03a2848f
commit
5f1cc64504
Notes:
sideshowbarker
2024-07-19 02:11:53 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/5f1cc64504b Pull-request: https://github.com/SerenityOS/serenity/pull/3618
1 changed files with 6 additions and 4 deletions
|
@ -293,10 +293,12 @@ Vector<AST::Command> Shell::expand_aliases(Vector<AST::Command> initial_commands
|
|||
auto* ast = static_cast<AST::Execute*>(subcommand_ast.ptr());
|
||||
subcommand_ast = ast->command();
|
||||
}
|
||||
NonnullRefPtr<AST::Node> substitute = adopt(*new AST::Join(subcommand_ast->position(),
|
||||
subcommand_ast.release_nonnull(),
|
||||
adopt(*new AST::CommandLiteral(subcommand_ast->position(), command))));
|
||||
for (auto& subst_command : substitute->run(*this)->resolve_as_commands(*this)) {
|
||||
auto subcommand_nonnull = subcommand_ast.release_nonnull();
|
||||
NonnullRefPtr<AST::Node> substitute = adopt(*new AST::Join(subcommand_nonnull->position(),
|
||||
subcommand_nonnull,
|
||||
adopt(*new AST::CommandLiteral(subcommand_nonnull->position(), command))));
|
||||
auto res = substitute->run(*this);
|
||||
for (auto& subst_command : res->resolve_as_commands(*this)) {
|
||||
if (!subst_command.argv.is_empty() && subst_command.argv.first() == argv0) // Disallow an alias resolving to itself.
|
||||
commands.append(subst_command);
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue