From ae10d085ba6d6dfb426e51aab39618c8d2ccd357 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sun, 3 Sep 2023 17:48:13 +0300 Subject: [PATCH] LibFileSystem: Replace PATH_MAX usage with heap allocation --- Userland/Libraries/LibFileSystem/FileSystem.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibFileSystem/FileSystem.cpp b/Userland/Libraries/LibFileSystem/FileSystem.cpp index 059f1392c1..e63ff317cb 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.cpp +++ b/Userland/Libraries/LibFileSystem/FileSystem.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -47,9 +48,9 @@ ErrorOr real_path(StringView path) if (path.is_null()) return Error::from_errno(ENOENT); - char buffer[PATH_MAX]; DeprecatedString dep_path = path; - auto* real_path = realpath(dep_path.characters(), buffer); + char* real_path = realpath(dep_path.characters(), nullptr); + ScopeGuard free_path = [real_path]() { free(real_path); }; if (!real_path) return Error::from_syscall("realpath"sv, -errno);