[libFuzzer] add -features_dir= flag to dump unique input features on disk
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer@358317 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/FuzzerIO.cpp b/FuzzerIO.cpp
index 423ab4b..a8140b6 100644
--- a/FuzzerIO.cpp
+++ b/FuzzerIO.cpp
@@ -61,10 +61,14 @@
}
void WriteToFile(const Unit &U, const std::string &Path) {
+ WriteToFile(U.data(), U.size(), Path);
+}
+
+void WriteToFile(const uint8_t *Data, size_t Size, const std::string &Path) {
// Use raw C interface because this function may be called from a sig handler.
FILE *Out = fopen(Path.c_str(), "wb");
if (!Out) return;
- fwrite(U.data(), sizeof(U[0]), U.size(), Out);
+ fwrite(Data, sizeof(Data[0]), Size, Out);
fclose(Out);
}