projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
592b2cc
)
[libFuzzer] use raw C IO to reduce the risk of a deadlock in a signal handler.
author
Kostya Serebryany
<kcc@google.com>
Wed, 12 Aug 2015 00:55:09 +0000
(
00:55
+0000)
committer
Kostya Serebryany
<kcc@google.com>
Wed, 12 Aug 2015 00:55:09 +0000
(
00:55
+0000)
llvm-svn: 244707
llvm/lib/Fuzzer/FuzzerIO.cpp
patch
|
blob
|
history
diff --git
a/llvm/lib/Fuzzer/FuzzerIO.cpp
b/llvm/lib/Fuzzer/FuzzerIO.cpp
index
1d25389
..
f0295e9
100644
(file)
--- a/
llvm/lib/Fuzzer/FuzzerIO.cpp
+++ b/
llvm/lib/Fuzzer/FuzzerIO.cpp
@@
-66,8
+66,11
@@
void CopyFileToErr(const std::string &Path) {
}
void WriteToFile(const Unit &U, const std::string &Path) {
- std::ofstream OF(Path);
- OF.write((const char*)U.data(), U.size());
+ // Use raw C interface because this function may be called from a sig handler.
+ 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,