[llvm] r176908 - [Support][Path] Don't inf loop if creating the parent directory fails.
Michael J. Spencer
bigcheesegs at gmail.com
Tue Mar 12 15:32:39 PDT 2013
Author: mspencer
Date: Tue Mar 12 17:32:39 2013
New Revision: 176908
URL: http://llvm.org/viewvc/llvm-project?rev=176908&view=rev
Log:
[Support][Path] Don't inf loop if creating the parent directory fails.
Patch by Paul Robinson.
Modified:
llvm/trunk/lib/Support/Windows/PathV2.inc
Modified: llvm/trunk/lib/Support/Windows/PathV2.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/PathV2.inc?rev=176908&r1=176907&r2=176908&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/PathV2.inc (original)
+++ llvm/trunk/lib/Support/Windows/PathV2.inc Tue Mar 12 17:32:39 2013
@@ -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))
More information about the llvm-commits
mailing list