mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
LibFileSystem: Fix leak in read_path
This commit is contained in:
parent
26a4e4d23d
commit
a8cd6c396b
Notes:
sideshowbarker
2024-07-17 11:30:05 +09:00
Author: https://github.com/cammo1123 Commit: https://github.com/SerenityOS/serenity/commit/a8cd6c396b Pull-request: https://github.com/SerenityOS/serenity/pull/17986 Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 4 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef AK_OS_SERENITY
|
||||
# include <serenity.h>
|
||||
|
@ -46,13 +47,14 @@ ErrorOr<String> 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(), nullptr);
|
||||
auto* real_path = realpath(dep_path.characters(), buffer);
|
||||
|
||||
if (!real_path)
|
||||
return Error::from_syscall("realpath"sv, -errno);
|
||||
|
||||
return TRY(String::from_deprecated_string({ real_path }));
|
||||
return TRY(String::from_utf8({ real_path, strlen(real_path) }));
|
||||
}
|
||||
|
||||
bool exists(StringView path)
|
||||
|
|
Loading…
Add table
Reference in a new issue