From e0f372c8b2b9a23e68d842271ecf601600396030 Mon Sep 17 00:00:00 2001 From: zhaoqin Date: Wed, 27 Jan 2016 12:37:52 -0800 Subject: Fix pdfium_fuzzer build failure on Windows - update ProgramPath to obtain program path on Windows R=aizatsky@chromium.org BUG= Review URL: https://codereview.chromium.org/1635793002 Cr-Commit-Position: refs/heads/master@{#371859} --- testing/libfuzzer/fuzzers/pdfium_fuzzer.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'testing/libfuzzer') diff --git a/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc b/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc index 4b23b59..ef1ec53 100644 --- a/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc +++ b/testing/libfuzzer/fuzzers/pdfium_fuzzer.cc @@ -9,7 +9,12 @@ #include #include #include + +#ifdef _MSC_VER +#include +#else #include +#endif #include #include @@ -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 { -- cgit v1.1