Fix error checking in get_temp_file_name().
Checking errno without first checking that the call failed means that if some other call prior to mkstemp failed with EINVAL prior to this, the assert would fire even if mkstemp succeeded. If something failed with EEXIST, it would go in to an infinite loop. Change-Id: I3f140a3e15fe08664a38a8c9a950c4ed547eb481 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@229035 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f2e36ef093
commit
1bd299a58e
@ -69,10 +69,13 @@ get_temp_file_name()
|
||||
std::string Name;
|
||||
int FD = -1;
|
||||
do {
|
||||
Name = "libcxx.XXXXXX";
|
||||
FD = mkstemp(&Name[0]);
|
||||
assert(errno != EINVAL && "Something is wrong with the mkstemp's argument");
|
||||
} while (FD == -1 || errno == EEXIST);
|
||||
Name = "libcxx.XXXXXX";
|
||||
FD = mkstemp(&Name[0]);
|
||||
if (FD == -1 && errno == EINVAL) {
|
||||
perror("mkstemp");
|
||||
abort();
|
||||
}
|
||||
} while (FD == -1);
|
||||
close(FD);
|
||||
return Name;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user