LibCore: Prevent infinite recursion in Directory::ensure_directory()

If a relative path was passed in, then repeatedly asking for its parent
will never reach `/`. The top-level path in that case is `.`.
This commit is contained in:
Sam Atkins 2022-04-13 11:52:16 +01:00 committed by Andreas Kling
commit 6967d37678
Notes: sideshowbarker 2024-07-17 11:50:52 +09:00

View file

@ -61,7 +61,7 @@ ErrorOr<Directory> Directory::create(LexicalPath path, CreateDirectories create_
ErrorOr<void> Directory::ensure_directory(LexicalPath const& path)
{
if (path.basename() == "/")
if (path.basename() == "/" || path.basename() == ".")
return {};
TRY(ensure_directory(path.parent()));