[PATCH] D28977: [libFuzzer] Implement TmpDir() for Windows.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 09:38:59 PST 2017


mpividori updated this revision to Diff 86304.
mpividori added a comment.

@amccarth  Thanks for your comment. Let me know if you agree with this new diff.


https://reviews.llvm.org/D28977

Files:
  lib/Fuzzer/FuzzerIOWindows.cpp


Index: lib/Fuzzer/FuzzerIOWindows.cpp
===================================================================
--- lib/Fuzzer/FuzzerIOWindows.cpp
+++ lib/Fuzzer/FuzzerIOWindows.cpp
@@ -287,7 +287,17 @@
   return FileName.substr(0, LocationLen + DirLen);
 }
 
-std::string TmpDir() { return "TODO: implement TmpDir"; }
+std::string TmpDir() {
+  std::string Tmp;
+  Tmp.resize(MAX_PATH + 1);
+  DWORD Size = GetTempPathA(Tmp.size(), &Tmp[0]);
+  if (Size == 0) {
+    Printf("Couldn't get Tmp path.\n");
+    exit(1);
+  }
+  Tmp.resize(Size);
+  return Tmp;
+}
 
 bool IsInterestingCoverageFile(const std::string &FileName) {
   if (FileName.find("Program Files") != std::string::npos)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28977.86304.patch
Type: text/x-patch
Size: 681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170130/00946988/attachment.bin>


More information about the llvm-commits mailing list