[libcxx] r229035 - Fix error checking in get_temp_file_name().
Dan Albert
danalbert at google.com
Thu Feb 12 19:02:29 PST 2015
Author: danalbert
Date: Thu Feb 12 21:02:28 2015
New Revision: 229035
URL: http://llvm.org/viewvc/llvm-project?rev=229035&view=rev
Log:
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
Modified:
libcxx/trunk/test/support/platform_support.h
Modified: libcxx/trunk/test/support/platform_support.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/platform_support.h?rev=229035&r1=229034&r2=229035&view=diff
==============================================================================
--- libcxx/trunk/test/support/platform_support.h (original)
+++ libcxx/trunk/test/support/platform_support.h Thu Feb 12 21:02:28 2015
@@ -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
More information about the cfe-commits
mailing list