1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

Kernel: Custody::absolute_path() => try_create_absolute_path()

This converts most users of Custody::absolute_path() to use the new
try_create_absolute_path() API, and return ENOMEM if the KString
allocation fails.
This commit is contained in:
Max Wipfli 2021-07-06 12:58:03 +02:00 committed by Andreas Kling
parent 0f8a6e574c
commit d5722eab36
4 changed files with 32 additions and 15 deletions

View file

@ -48,7 +48,10 @@ KResultOr<FlatPtr> Process::sys$getcwd(Userspace<char*> buffer, size_t size)
if (size > NumericLimits<ssize_t>::max())
return EINVAL;
auto path = current_directory().absolute_path();
auto maybe_path = current_directory().try_create_absolute_path();
if (!maybe_path)
return ENOMEM;
auto& path = *maybe_path;
size_t ideal_size = path.length() + 1;
auto size_to_copy = min(ideal_size, size);