diff --git a/lib/Fuzzer/FuzzerIO.cpp b/lib/Fuzzer/FuzzerIO.cpp index 45445fa3ba4..e3f609ed8a8 100644 --- a/lib/Fuzzer/FuzzerIO.cpp +++ b/lib/Fuzzer/FuzzerIO.cpp @@ -96,7 +96,8 @@ void DupAndCloseStderr() { if (NewOutputFile) { OutputFile = NewOutputFile; if (EF->__sanitizer_set_report_fd) - EF->__sanitizer_set_report_fd(reinterpret_cast(OutputFd)); + EF->__sanitizer_set_report_fd( + reinterpret_cast(GetHandleFromFd(OutputFd))); DiscardOutput(2); } } diff --git a/lib/Fuzzer/FuzzerIO.h b/lib/Fuzzer/FuzzerIO.h index 28c6ba09586..3b66a52d1a6 100644 --- a/lib/Fuzzer/FuzzerIO.h +++ b/lib/Fuzzer/FuzzerIO.h @@ -69,6 +69,8 @@ void RemoveFile(const std::string &Path); void DiscardOutput(int Fd); +intptr_t GetHandleFromFd(int fd); + } // namespace fuzzer #endif // LLVM_FUZZER_IO_H diff --git a/lib/Fuzzer/FuzzerIOPosix.cpp b/lib/Fuzzer/FuzzerIOPosix.cpp index 40209a034e3..c5ebdbac467 100644 --- a/lib/Fuzzer/FuzzerIOPosix.cpp +++ b/lib/Fuzzer/FuzzerIOPosix.cpp @@ -83,6 +83,10 @@ void DiscardOutput(int Fd) { fclose(Temp); } +intptr_t GetHandleFromFd(int fd) { + return static_cast(fd); +} + std::string DirName(const std::string &FileName) { char *Tmp = new char[FileName.size() + 1]; memcpy(Tmp, FileName.c_str(), FileName.size() + 1); diff --git a/lib/Fuzzer/FuzzerIOWindows.cpp b/lib/Fuzzer/FuzzerIOWindows.cpp index 536e1306725..75d4e3a0607 100644 --- a/lib/Fuzzer/FuzzerIOWindows.cpp +++ b/lib/Fuzzer/FuzzerIOWindows.cpp @@ -149,6 +149,10 @@ void DiscardOutput(int Fd) { fclose(Temp); } +intptr_t GetHandleFromFd(int fd) { + return _get_osfhandle(fd); +} + static bool IsSeparator(char C) { return C == '\\' || C == '/'; }