[libFuzzer] use raw C IO to reduce the risk of a deadlock in a signal handler.

llvm-svn: 244707
This commit is contained in:
Kostya Serebryany 2015-08-12 00:55:09 +00:00
parent 592b2cc246
commit ac25eeba76
1 changed files with 5 additions and 2 deletions

View File

@ -66,8 +66,11 @@ void CopyFileToErr(const std::string &Path) {
} }
void WriteToFile(const Unit &U, const std::string &Path) { void WriteToFile(const Unit &U, const std::string &Path) {
std::ofstream OF(Path); // Use raw C interface because this function may be called from a sig handler.
OF.write((const char*)U.data(), U.size()); FILE *Out = fopen(Path.c_str(), "w");
if (!Out) return;
fwrite(U.data(), sizeof(U[0]), U.size(), Out);
fclose(Out);
} }
void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit> *V, void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit> *V,