summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/PathV2.inc
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-03-12 22:32:39 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-03-12 22:32:39 +0000
commit20a11b25349bf99e7095479e012d26439a087cde (patch)
treea9e3013a0346176c7bb51e9b5a221e80422c4cf0 /llvm/lib/Support/Windows/PathV2.inc
parenta4f770d51c402de8a8f379121aa746af37c52779 (diff)
downloadbcm5719-llvm-20a11b25349bf99e7095479e012d26439a087cde.tar.gz
bcm5719-llvm-20a11b25349bf99e7095479e012d26439a087cde.zip
[Support][Path] Don't inf loop if creating the parent directory fails.
Patch by Paul Robinson. llvm-svn: 176908
Diffstat (limited to 'llvm/lib/Support/Windows/PathV2.inc')
-rw-r--r--llvm/lib/Support/Windows/PathV2.inc8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Support/Windows/PathV2.inc b/llvm/lib/Support/Windows/PathV2.inc
index 2e6cc96e7f1..823f7583dac 100644
--- a/llvm/lib/Support/Windows/PathV2.inc
+++ b/llvm/lib/Support/Windows/PathV2.inc
@@ -593,6 +593,10 @@ retry_random_path:
random_path_utf16.push_back(0);
random_path_utf16.pop_back();
+ // Make sure we don't fall into an infinite loop by constantly trying
+ // to create the parent path.
+ bool TriedToCreateParent = false;
+
// Try to create + open the path.
retry_create_file:
HANDLE TempFileHandle = ::CreateFileW(random_path_utf16.begin(),
@@ -610,7 +614,9 @@ retry_create_file:
if (ec == windows_error::file_exists)
goto retry_random_path;
// Check for non-existing parent directories.
- if (ec == windows_error::path_not_found) {
+ if (ec == windows_error::path_not_found && !TriedToCreateParent) {
+ TriedToCreateParent = true;
+
// Create the directories using result_path as temp storage.
if (error_code ec = UTF16ToUTF8(random_path_utf16.begin(),
random_path_utf16.size(), result_path))
OpenPOWER on IntegriCloud