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 | 39fb408fd3ce922dc302e18eec10e07db3edfe6b (patch) | |
| tree | 04d7204b97bb864f2a3620f8c69f92680358a5f0 /llvm | |
| parent | 1c76f15aa77033a61e548dd6de3e5e0c79c7063f (diff) | |
| download | bcm5719-llvm-39fb408fd3ce922dc302e18eec10e07db3edfe6b.tar.gz bcm5719-llvm-39fb408fd3ce922dc302e18eec10e07db3edfe6b.zip | |
[PathV2]: Fix bug in create_directories which caused infinite recursion on
som inputs.
Bug found and fix proposed by Kal Conley!
llvm-svn: 153225
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Support/PathV2.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp index 786e1a12c30..e2a69a650db 100644 --- a/llvm/lib/Support/PathV2.cpp +++ b/llvm/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); } |

