diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-06-29 16:46:16 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-30 11:13:54 +0200 |
commit | fc6d051dfdddc13835548537d025e760ba186b5b (patch) | |
tree | 12a5602dd4efc20f023fea95d390f3e241f6f9cf /Userland/DevTools/UserspaceEmulator/Emulator.cpp | |
parent | 9b8f35259c375f6911b76c38ec37e6d422b26bbe (diff) | |
download | serenity-fc6d051dfdddc13835548537d025e760ba186b5b.zip |
AK+Everywhere: Add and use static APIs for LexicalPath
The LexicalPath instance methods dirname(), basename(), title() and
extension() will be changed to return StringView const& in a further
commit. Due to this, users creating temporary LexicalPath objects just
to call one of those getters will recieve a StringView const& pointing
to a possible freed buffer.
To avoid this, static methods for those APIs have been added, which will
return a String by value to avoid those problems. All cases where
temporary LexicalPath objects have been used as described above haven
been changed to use the static APIs.
Diffstat (limited to 'Userland/DevTools/UserspaceEmulator/Emulator.cpp')
-rw-r--r-- | Userland/DevTools/UserspaceEmulator/Emulator.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index 239f8e6a2c..4529bcb1a6 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -426,7 +426,7 @@ String Emulator::create_backtrace_line(FlatPtr address) auto source_position = it->value.debug_info->get_source_position(address - region->base()); if (source_position.has_value()) - return String::formatted("=={{{}}}== {:p} [{}]: {} (\e[34;1m{}\e[0m:{})", getpid(), (void*)address, lib_name, symbol, LexicalPath(source_position.value().file_path).basename(), source_position.value().line_number); + return String::formatted("=={{{}}}== {:p} [{}]: {} (\e[34;1m{}\e[0m:{})", getpid(), (void*)address, lib_name, symbol, LexicalPath::basename(source_position.value().file_path), source_position.value().line_number); return line_without_source_info; } @@ -464,7 +464,7 @@ String Emulator::create_instruction_line(FlatPtr address, X86::Instruction insn) if (!source_position.has_value()) return minimal; - return String::formatted("{:p}: {} \e[34;1m{}\e[0m:{}", (void*)address, insn.to_string(address), LexicalPath(source_position.value().file_path).basename(), source_position.value().line_number); + return String::formatted("{:p}: {} \e[34;1m{}\e[0m:{}", (void*)address, insn.to_string(address), LexicalPath::basename(source_position.value().file_path), source_position.value().line_number); } static void emulator_signal_handler(int signum) |