diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-03-21 23:09:14 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-03-21 23:09:14 +0000 |
commit | 55f43d6b7e3ad1f08f5392205ab0feabf4c9933d (patch) | |
tree | c6b792980633c6a1dd48de643ce1c16388fdd1fd | |
parent | 98a92d199ce9993dca1b65927009013ad3e5297f (diff) |
[PathV2]: Fix bug in create_directories which caused infinite recursion on
som inputs.
Bug found and fix proposed by Kal Conley!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153225 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Support/PathV2.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp index 786e1a12c3..e2a69a650d 100644 --- a/lib/Support/PathV2.cpp +++ b/lib/Support/PathV2.cpp @@ -654,12 +654,13 @@ error_code create_directories(const Twine &path, bool &existed) { StringRef p = path.toStringRef(path_storage); StringRef parent = path::parent_path(p); - bool parent_exists; + if (!parent.empty()) { + bool parent_exists; + if (error_code ec = fs::exists(parent, parent_exists)) return ec; - if (error_code ec = fs::exists(parent, parent_exists)) return ec; - - if (!parent_exists) - if (error_code ec = create_directories(parent, existed)) return ec; + if (!parent_exists) + if (error_code ec = create_directories(parent, existed)) return ec; + } return create_directory(p, existed); } |