Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Unified Diff: testing/libfuzzer/fuzzers/pdfium_fuzzer.cc

Issue 1635793002: Fix pdfium_fuzzer build failure on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/fuzzers/pdfium_fuzzer.cc
diff --git a/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc b/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc
index 4b23b5973cac10f1f389d691563f4d6c0eae1989..ef1ec53b9ce6b01f613483764dde090088076548 100644
--- a/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc
+++ b/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc
@@ -9,7 +9,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#ifdef _MSC_VER
+#include <Windows.h>
+#else
#include <unistd.h>
+#endif
#include <list>
#include <sstream>
@@ -164,6 +169,14 @@ static void RenderPdf(const char* pBuf, size_t len) {
}
std::string ProgramPath() {
+#ifdef _MSC_VER
+ wchar_t wpath[MAX_PATH];
+ char path[MAX_PATH];
+ DWORD res = GetModuleFileName(NULL, wpath, MAX_PATH);
+ assert(res != 0);
+ wcstombs(path, wpath, MAX_PATH);
+ return std::string(path, res);
+#else
char *path = new char[PATH_MAX + 1];
assert(path);
ssize_t sz = readlink("/proc/self/exe", path, PATH_MAX);
@@ -171,6 +184,7 @@ std::string ProgramPath() {
std::string result(path, sz);
delete[] path;
return result;
+#endif
}
struct TestCase {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698