mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
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
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;
|
StringView exec_filename;
|
||||||
|
String resolved_executable_path;
|
||||||
if (search_in_path == SearchInPath::Yes) {
|
if (search_in_path == SearchInPath::Yes) {
|
||||||
auto executable_or_error = resolve_executable_from_environment(filename);
|
auto executable_or_error = resolve_executable_from_environment(filename);
|
||||||
|
|
||||||
if (executable_or_error.is_error())
|
if (executable_or_error.is_error())
|
||||||
return executable_or_error.release_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 {
|
} else {
|
||||||
exec_filename = filename;
|
exec_filename = filename;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue