From 22ea2f638a24c48eb30275ecf529460cec492234 Mon Sep 17 00:00:00 2001 From: Kemal Zebari Date: Mon, 15 Jan 2024 12:14:30 -0800 Subject: [PATCH] mktemp: Make sure to use target directory option argument Previously, we ignored the -p argument if it was specified. This would resort in a crash because final_target_directory wasn't given a value. This snapshot does away with giving this variable an Optional<> and just has the -p argument be its default value. --- Userland/Utilities/mktemp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/mktemp.cpp b/Userland/Utilities/mktemp.cpp index aacfa91bbd..71429a3539 100644 --- a/Userland/Utilities/mktemp.cpp +++ b/Userland/Utilities/mktemp.cpp @@ -72,7 +72,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); Optional final_file_template; - Optional final_target_directory; + ByteString final_target_directory = target_directory; if (target_directory.is_empty()) { if (!file_template.is_empty()) { @@ -97,7 +97,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return 1; } - auto target_path = LexicalPath::join(final_target_directory.value(), final_file_template.value()).string(); + auto target_path = LexicalPath::join(final_target_directory, final_file_template.value()).string(); auto final_path = TRY(make_temp(target_path, create_directory, dry_run)); if (!final_path.has_value()) {