From 6967d376786ed3f02dcd968a08aa67fd0381231e Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 13 Apr 2022 11:52:16 +0100 Subject: [PATCH] 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 `.`. --- Userland/Libraries/LibCore/Directory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCore/Directory.cpp b/Userland/Libraries/LibCore/Directory.cpp index 32725992e2..a51531819d 100644 --- a/Userland/Libraries/LibCore/Directory.cpp +++ b/Userland/Libraries/LibCore/Directory.cpp @@ -61,7 +61,7 @@ ErrorOr Directory::create(LexicalPath path, CreateDirectories create_ ErrorOr Directory::ensure_directory(LexicalPath const& path) { - if (path.basename() == "/") + if (path.basename() == "/" || path.basename() == ".") return {}; TRY(ensure_directory(path.parent()));