From 4797fad91c35f23aeabdaeb49dbe817a36ba44ed Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 7 Mar 2023 09:42:20 +0100 Subject: [PATCH] Shell: Fix bogus C-style casts from `NonnullOwnPtr*` to `T*` Thanks UBSAN for spotting this! --- Userland/Shell/AST.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index ca53f40cfd..e675ca2fee 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -49,7 +49,7 @@ ErrorOr AK::Formatter::format(FormatBuilder& builder, for (auto& redir : value.redirections) { TRY(builder.put_padding(' ', 1)); if (redir->is_path_redirection()) { - auto path_redir = (Shell::AST::PathRedirection const*)&redir; + auto path_redir = static_cast(redir.ptr()); TRY(builder.put_i64(path_redir->fd)); switch (path_redir->direction) { case Shell::AST::PathRedirection::Read: @@ -67,12 +67,12 @@ ErrorOr AK::Formatter::format(FormatBuilder& builder, } TRY(builder.put_literal(path_redir->path)); } else if (redir->is_fd_redirection()) { - auto* fdredir = (Shell::AST::FdRedirection const*)&redir; + auto* fdredir = static_cast(redir.ptr()); TRY(builder.put_i64(fdredir->new_fd)); TRY(builder.put_literal(">"sv)); TRY(builder.put_i64(fdredir->old_fd)); } else if (redir->is_close_redirection()) { - auto close_redir = (Shell::AST::CloseRedirection const*)&redir; + auto close_redir = static_cast(redir.ptr()); TRY(builder.put_i64(close_redir->fd)); TRY(builder.put_literal(">&-"sv)); } else {