summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-05-17 20:43:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-17 20:43:42 +0000
commitdd8da5e2f0f4558d98a8a6f93f9cb14b5b091277 (patch)
tree84bfb5c6bbafbf35732441142acb9413cabad941 /samples
parentc524fc91aa42a8e34b4daf9a67fa283e25f48560 (diff)
downloadpdfium-dd8da5e2f0f4558d98a8a6f93f9cb14b5b091277.tar.xz
Add check that --font-dir is actually a directorychromium/3434
Hoisted myself on this today when I was actually passing the path to the font file I wanted to use, not the directory. BUG=pdfium:1008,pdfium:1020 Change-Id: I4a68a7d96633e951a92125d83397ff457288b1e0 Reviewed-on: https://pdfium-review.googlesource.com/32636 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'samples')
-rw-r--r--samples/pdfium_test.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 347982cf09..c7c1a3af75 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -33,6 +33,7 @@
#include "samples/pdfium_test_event_helper.h"
#include "samples/pdfium_test_write_helper.h"
#include "testing/test_support.h"
+#include "testing/utils/path_service.h"
#include "third_party/base/logging.h"
#include "third_party/base/optional.h"
@@ -325,7 +326,7 @@ bool ParseCommandLine(const std::vector<std::string>& args,
return false;
}
options->output_format = OUTPUT_SKP;
-#endif
+#endif // PDF_ENABLE_SKIA
} else if (cur_arg.size() > 11 &&
cur_arg.compare(0, 11, "--font-dir=") == 0) {
if (!options->font_directory.empty()) {
@@ -338,6 +339,13 @@ bool ParseCommandLine(const std::vector<std::string>& args,
fprintf(stderr, "Failed to expand --font-dir, %s\n", path.c_str());
return false;
}
+
+ if (!PathService::DirectoryExists(expanded_path.value())) {
+ fprintf(stderr, "--font-dir, %s, appears to not be a directory\n",
+ path.c_str());
+ return false;
+ }
+
options->font_directory = expanded_path.value();
#ifdef _WIN32
@@ -763,7 +771,7 @@ void RenderPdf(const std::string& name,
void ShowConfig() {
std::string config;
std::string maybe_comma;
-#if PDF_ENABLE_V8
+#ifdef PDF_ENABLE_V8
config.append(maybe_comma);
config.append("V8");
maybe_comma = ",";