LibCore: Ensure exec()
keeps a reference to the executable path
When called with `SearchInPath::Yes`, calls to `Core::System::exec()` would fail. The value returned from `resolve_executable_from_environment()` was assigned to a StringView, but the original reference was not kept, causing the StringView to appear empty.
This commit is contained in:
parent
0177e4e6ba
commit
cbe5aeb917
Notes:
sideshowbarker
2024-07-17 03:03:44 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/cbe5aeb917 Pull-request: https://github.com/SerenityOS/serenity/pull/19307 Reviewed-by: https://github.com/gmta ✅
1 changed files with 3 additions and 2 deletions
|
@ -1263,14 +1263,15 @@ ErrorOr<void> exec(StringView filename, ReadonlySpan<StringView> arguments, Sear
|
|||
};
|
||||
|
||||
StringView exec_filename;
|
||||
|
||||
String resolved_executable_path;
|
||||
if (search_in_path == SearchInPath::Yes) {
|
||||
auto executable_or_error = resolve_executable_from_environment(filename);
|
||||
|
||||
if (executable_or_error.is_error())
|
||||
return executable_or_error.release_error();
|
||||
|
||||
exec_filename = executable_or_error.value();
|
||||
resolved_executable_path = executable_or_error.release_value();
|
||||
exec_filename = resolved_executable_path;
|
||||
} else {
|
||||
exec_filename = filename;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue